> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wyvern.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Wyvern Pipeline

## Set Up Pipeline

A Wyvern pipeline is the API route that defines the logistics of your ML application pipeline and it defines the API endpoint of yours. There are a couple of inputs:

* REQUEST\_SCHEMA\_CLASS: the class of the request schema. This is used to validate the request data.
* RESPONSE\_SCHEMA\_CLASS: the class of the response schema. This is used to validate the response data.
* PATH: the path of the API. This is used in the API routing.
* (Optional) API\_VERSION: the version of the API. This is used in the API routing. The default value is "v1". As a result, the final url of your pipeline will be `/api/v1/{your PATH}`
* (Optional) API\_NAME: the name of the API. This is used in the API routing. If not provided, the name of the pipeline component class will be used by default.

Now let's define a PipelineComponent under `pipelines/product_ranking/ranking_pipeline.py`:

```python pipelines/product_ranking/ranking_pipeline.py theme={null}
from wyvern import (
    ModelComponent,
    RankingPipeline,
    RankingResponse,
)

from pipelines.product_ranking.models import RankingModel
from pipelines.product_ranking.schemas import MyRankingRequest, Product


class MyRankingPipeline(RankingPipeline[Product]):
    REQUEST_SCHEMA_CLASS = MyRankingRequest
    RESPONSE_SCHEMA_CLASS = RankingResponse
    PATH = "/my-ranking"
    API_VERSION = "/v1"

    def get_model(self) -> ModelComponent:
        return RankingModel()
```

With this example, MyRankingRequest is the request schema and RankingResponse is the response schema. And the API url is `/api/v1/my-ranking`

## Register Pipelines

Similar to registering realtime features, register the pipeline with the Wyvern service in `pipelines/main.py`:

```python pipelines/main.py theme={null}
from wyvern import WyvernService

from pipelines.product_ranking.ranking_pipeline import MyRankingPipeline
from pipelines.product_ranking.realtime_features import (
    RealtimeProductFeature,
    RealtimeProductQueryFeature,
)

app = WyvernService.generate_app(
    route_components=[MyRankingPipeline],
    realtime_feature_components=[RealtimeProductFeature, RealtimeProductQueryFeature],
)
```

To register the pipeline, pass the the route\_components as a list, containing your pipelines, to `WyvernService.generate_app`. This basically register the /api/v1/ranking route in the Wyvern service.

Now if you do `wyvern run`, your ranking endpoint is ready to serve a request.
