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

# Use Modellix LLM with CrewAI

> Point CrewAI at Modellix with LLM base_url, a Modellix API key, provider/name model IDs, and custom_openai for OpenAI-compatible routing.

Use [CrewAI](https://docs.crewai.com/en/learn/llm-connections) against the Modellix LLM gateway. Pass an OpenAI-compatible `base_url` of `https://llm.modellix.ai/v1` to the built-in `LLM` class — you do **not** need a custom `BaseLLM` subclass for Modellix.

<Note>
  This page covers **LLM text** only (`https://llm.modellix.ai`).

  Modellix model IDs are `provider/name` (for example `openai/gpt-5.5`). Set that full string as `model`. See [Models & Pricing](/llm/overview#models-and-pricing).

  [Custom LLM (`BaseLLM`)](https://docs.crewai.com/en/learn/custom-llm) is for non-OpenAI protocols or special auth. Prefer the `LLM` + `base_url` path below for Modellix.
</Note>

## Set Up CrewAI

<Steps>
  <Step title="Install CrewAI">
    ```bash theme={null}
    pip install "crewai[openai]"
    ```

    Or with [uv](https://docs.astral.sh/uv/):

    ```bash theme={null}
    uv add "crewai[openai]"
    ```

    The `[openai]` extra covers the native OpenAI-compatible client path used with `custom_openai=True`.
  </Step>

  <Step title="Set Credentials">
    Create a Modellix API key in the [console](https://modellix.ai/console/api-key):

    ```bash theme={null}
    export OPENAI_API_KEY="mdlx-xxxxxxxx"
    export OPENAI_BASE_URL="https://llm.modellix.ai/v1"
    # Legacy alias also works:
    # export OPENAI_API_BASE="https://llm.modellix.ai/v1"
    ```

    | Setting                        | Value                                        |
    | ------------------------------ | -------------------------------------------- |
    | `api_key` / `OPENAI_API_KEY`   | Modellix API Key                             |
    | `base_url` / `OPENAI_BASE_URL` | `https://llm.modellix.ai/v1` (include `/v1`) |
    | `model`                        | Exact Modellix Model ID (`provider/name`)    |

    <Warning>
      Use a Modellix key, not an OpenAI platform key. Do not point CrewAI at the media host (`https://api.modellix.ai`). Prefer setting `base_url` (or `custom_openai=True` with env vars) so traffic does not fall back to `api.openai.com`.
    </Warning>
  </Step>

  <Step title="Create an LLM Pointed at Modellix">
    Recommended: construct `LLM` with an explicit `base_url` and `custom_openai=True` so CrewAI uses the native OpenAI SDK against your gateway:

    ```python theme={null}
    from crewai import Agent, Crew, LLM, Task

    llm = LLM(
        model="openai/gpt-5.5",
        api_key="mdlx-xxxxxxxx",  # or rely on OPENAI_API_KEY
        base_url="https://llm.modellix.ai/v1",
        custom_openai=True,
        temperature=0.7,
    )

    agent = Agent(
        role="Coding Assistant",
        goal="Help with concise coding tasks",
        backstory="You are a careful software engineer.",
        llm=llm,
    )

    task = Task(
        description="Introduce yourself in one sentence.",
        expected_output="A single short sentence",
        agent=agent,
    )

    crew = Crew(agents=[agent], tasks=[task])
    result = crew.kickoff()
    print(result)
    ```

    Change `model` to any catalog ID (`anthropic/claude-sonnet-5`, `google/gemini-3.6-flash`, and so on). Traffic still uses Chat Completions on `https://llm.modellix.ai/v1`.

    <Warning>
      On some CrewAI versions, a leading `openai/` routing prefix may be stripped before the request is sent. If `openai/gpt-5.5` fails with model-not-found, confirm the upstream `model` field still includes `openai/`. Prefer `custom_openai=True` with an explicit `base_url`, and try a non-`openai/` catalog ID (for example `anthropic/claude-sonnet-5`) to verify the gateway path first.
    </Warning>

    <Tip>
      If `OPENAI_BASE_URL` / `OPENAI_API_BASE` is already set, you can omit `base_url` in code, but keep `custom_openai=True` for unknown / namespaced model IDs so CrewAI does not route to the default OpenAI host. For the native OpenAI SDK path, install `crewai[openai]`.
    </Tip>
  </Step>

  <Step title="Optional: Environment-Only Configuration">
    ```bash theme={null}
    export OPENAI_API_KEY="mdlx-xxxxxxxx"
    export OPENAI_BASE_URL="https://llm.modellix.ai/v1"
    export OPENAI_MODEL_NAME="openai/gpt-5.5"
    ```

    ```python theme={null}
    from crewai import Agent, LLM

    llm = LLM(model="openai/gpt-5.5", custom_openai=True)
    agent = Agent(
        role="Assistant",
        goal="Help users",
        backstory="A helpful assistant.",
        llm=llm,
    )
    ```

    CrewAI resolves the base URL from `base_url`, then `api_base`, then `OPENAI_BASE_URL`, then legacy `OPENAI_API_BASE`.
  </Step>

  <Step title="Optional: Multi-Agent Crew">
    Share one Modellix `LLM` across agents, or give each agent a different catalog ID on the same gateway:

    ```python theme={null}
    primary = LLM(
        model="openai/gpt-5.5",
        base_url="https://llm.modellix.ai/v1",
        api_key="mdlx-xxxxxxxx",
        custom_openai=True,
    )
    fast = LLM(
        model="google/gemini-3.6-flash",
        base_url="https://llm.modellix.ai/v1",
        api_key="mdlx-xxxxxxxx",
        custom_openai=True,
    )

    researcher = Agent(
        role="Researcher",
        goal="Gather facts",
        backstory="You research carefully.",
        llm=primary,
    )
    writer = Agent(
        role="Writer",
        goal="Write concise summaries",
        backstory="You write clearly.",
        llm=fast,
    )
    ```
  </Step>
</Steps>

## Troubleshooting

| Symptom                     | Check                                                                                                                             |
| --------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| Still hitting OpenAI        | Set `base_url` and/or `custom_openai=True`; key is a Modellix key                                                                 |
| 401 Unauthorized            | `api_key` / `OPENAI_API_KEY` is valid                                                                                             |
| Model not found / 404       | `model` is a full ID like `openai/gpt-5.5`; if `openai/` was stripped, try another catalog prefix or inspect the outbound request |
| Wrong path                  | `base_url` is `https://llm.modellix.ai/v1` (include `/v1`)                                                                        |
| Env vs constructor conflict | Prefer per-`LLM` `base_url` + `api_key` for multi-provider setups                                                                 |

## Related

* [CrewAI — Connect to any LLM](https://docs.crewai.com/en/learn/llm-connections) — `LLM`, `base_url`, OpenAI-compatible setup
* [CrewAI — Custom LLM](https://docs.crewai.com/en/learn/custom-llm) — `BaseLLM` for non-standard protocols
* [LiteLLM removal / custom\_openai](https://docs.crewai.com/edge/en/learn/litellm-removal-guide) — native OpenAI-compatible routing
* [OpenAI SDK](/llm/sdk/openai-sdk) — same `/v1` gateway without CrewAI
* [Models & Pricing](/llm/overview#models-and-pricing) — Model IDs and rates
* [LLM API guide](/llm/api/api) — protocols and curl examples
