# Example

You can deploy an API by providing a project directory. Cortex will save the project directory and make it available during API initialization.

```bash
project/
  ├── model.py
  ├── util.py
  ├── predictor.py
  ├── requirements.txt
  └── ...
```

You can define your Predictor class in a separate python file and import code from your project.

```python
# predictor.py

from model import MyModel

class PythonPredictor:
    def __init__(self, config):
        model = MyModel()

    def predict(payload):
        return model(payload)
```

## Deploy using the Python Client

```python
import cortex

api_spec = {
    "name": "text-generator",
    "kind": "RealtimeAPI",
    "predictor": {
        "type": "python",
        "path": "predictor.py"
    }
}

cx = cortex.client("aws")
cx.create_api(api_spec, project_dir=".")
```

## Deploy using the CLI

```yaml
# api.yaml

- name: text-generator
  kind: RealtimeAPI
  predictor:
    type: python
    path: predictor.py
```

```bash
cortex deploy api.yaml
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cortexlabs.com/0.32/workloads/dependencies/example.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
