# LiteLLM (/docs/guides/litellm)

Call cheapaimodel models from the LiteLLM Python SDK, or serve them through LiteLLM Proxy.



LiteLLM reaches OpenAI-compatible services through its `openai/` model prefix. Use it directly from Python, or list cheapaimodel models in a LiteLLM Proxy config.

|          | LiteLLM setting | Value                                                                             |
| -------- | --------------- | --------------------------------------------------------------------------------- |
| Base URL | `api_base`      | `https://api.cheapaimodel.ai/v1`                                                  |
| API key  | `api_key`       | Your key from the console's [API Keys](https://console.cheapaimodel.ai/keys) page |
| Model ID | `model`         | `openai/deepseek-v4-1-flash`: `openai/` plus any ID from the [catalog](/models)   |

## Set it up [#set-it-up]

<Tabs items="[&#x22;Python SDK&#x22;, &#x22;Proxy&#x22;]">
  <Tab value="Python SDK">
    ```bash title="Terminal"
    pip install litellm
    ```

    ```python title="app.py"
    import os
    import litellm

    response = litellm.completion(
        model="openai/deepseek-v4-1-flash",
        api_base="https://api.cheapaimodel.ai/v1",
        api_key=os.environ["CHEAPAIMODEL_API_KEY"],
        messages=[{"role": "user", "content": "Explain recursion in one sentence."}],
    )
    print(response.choices[0].message.content)

    # Streaming
    stream = litellm.completion(
        model="openai/deepseek-v4-1-flash",
        api_base="https://api.cheapaimodel.ai/v1",
        api_key=os.environ["CHEAPAIMODEL_API_KEY"],
        messages=[{"role": "user", "content": "Write a haiku about rivers."}],
        stream=True,
    )
    for chunk in stream:
        print(chunk.choices[0].delta.content or "", end="", flush=True)
    ```

    LiteLLM drops the `openai/` prefix before sending, so the request reaches `/v1/chat/completions` with `"model": "deepseek-v4-1-flash"`.
  </Tab>

  <Tab value="Proxy">
    ```bash title="Terminal"
    pip install 'litellm[proxy]'
    ```

    ```yaml title="config.yaml"
    model_list:
      - model_name: deepseek-v4-1-flash
        litellm_params:
          model: openai/deepseek-v4-1-flash
          api_base: https://api.cheapaimodel.ai/v1
          api_key: os.environ/CHEAPAIMODEL_API_KEY

    general_settings:
      master_key: os.environ/LITELLM_MASTER_KEY
    ```

    Add one entry per model. `model_name` is the name your clients send to the proxy. Current LiteLLM releases refuse to start the proxy without a master key; clients authenticate with it, and the proxy calls cheapaimodel with your cheapaimodel key.

    ```bash title="Terminal"
    export CHEAPAIMODEL_API_KEY="sk-..."
    export LITELLM_MASTER_KEY="sk-$(openssl rand -hex 32)"
    litellm --config config.yaml
    ```

    ```bash title="Terminal"
    curl http://localhost:4000/v1/chat/completions \
      -H "Authorization: Bearer $LITELLM_MASTER_KEY" \
      -H "Content-Type: application/json" \
      -d '{"model": "deepseek-v4-1-flash", "messages": [{"role": "user", "content": "Hello"}]}'
    ```
  </Tab>
</Tabs>

## Common mistakes [#common-mistakes]

* **`LLM Provider NOT provided. Pass in the LLM provider you are trying to call. You passed model=deepseek-v4-1-flash`.** The `openai/` prefix is missing. LiteLLM uses the prefix to pick the provider and fails before sending anything. Write `openai/deepseek-v4-1-flash`.
* **`litellm.NotFoundError` or `Invalid URL (POST /v1/chat/completions/chat/completions)`.** `api_base` is missing `/v1`, or it includes the endpoint path. Set it to exactly `https://api.cheapaimodel.ai/v1`.
* **Embeddings pointed at cheapaimodel.** cheapaimodel has no embedding models yet, so `litellm.embedding()` or an embedding entry in `model_list` has nothing to call here. Keep embeddings on another provider.
* **LiteLLM shows no cost for these calls.** Its built-in price list doesn't include cheapaimodel models: the proxy records a cost of 0, and `litellm.completion_cost()` raises `This model isn't mapped yet`. Your real spend is on the console's [Logs](https://console.cheapaimodel.ai/logs) page. To track it in the proxy, set `input_cost_per_token` and `output_cost_per_token` under the entry's `model_info`: the per-million-token prices on the [model page](/models/deepseek-v4-1-flash), divided by 1,000,000.
