> ## 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 the OpenAI SDK

> Point the OpenAI SDK at the Modellix LLM gateway with OPENAI_BASE_URL and your Modellix API key, then call Chat Completions or Responses with provider/name models.

Use the official OpenAI client libraries against Modellix by setting the base URL to the LLM gateway and using a Modellix API key. Requests are synchronous and can stream over SSE.

<Note>
  Use a Modellix API key from the [console](https://modellix.ai/console/api-key), not an OpenAI platform key. Model IDs use `provider/name` (for example `openai/gpt-5.5`)—see [Models & Pricing](/llm/overview#models-and-pricing) for the full list.
</Note>

## Configure the client

```bash theme={null}
export OPENAI_API_KEY="mdlx-xxxxxxxx"
export OPENAI_BASE_URL="https://llm.modellix.ai/v1"
```

| Setting  | Value                                                                                                                          |
| -------- | ------------------------------------------------------------------------------------------------------------------------------ |
| Base URL | `https://llm.modellix.ai/v1` (include `/v1`)                                                                                   |
| API key  | Modellix API Key via `OPENAI_API_KEY`                                                                                          |
| Model    | Prefer `openai/...` (or `google/...` on the OpenAI-compatible path). See [Models & Pricing](/llm/overview#models-and-pricing). |

Then call the SDK as usual. Chat Completions maps to [`POST /v1/chat/completions`](/llm/chat-completions); Responses maps to [`POST /v1/responses`](/llm/responses).

## Chat Completions example

<CodeGroup>
  ```python Python theme={null}
  from openai import OpenAI

  client = OpenAI()  # reads OPENAI_API_KEY and OPENAI_BASE_URL

  completion = client.chat.completions.create(
      model="openai/gpt-5.5",
      messages=[
          {"role": "user", "content": "Introduce yourself in one sentence"},
      ],
      max_tokens=256,
  )

  print(completion.choices[0].message.content)
  ```

  ```typescript TypeScript theme={null}
  import OpenAI from "openai";

  const client = new OpenAI(); // reads OPENAI_API_KEY and OPENAI_BASE_URL

  const completion = await client.chat.completions.create({
    model: "openai/gpt-5.5",
    messages: [{ role: "user", content: "Introduce yourself in one sentence" }],
    max_tokens: 256,
  });

  console.log(completion.choices[0].message.content);
  ```
</CodeGroup>

## Streaming

Set `stream=true` (or the SDK equivalent). The gateway returns `text/event-stream` with OpenAI-style `chat.completion.chunk` events ending in `data: [DONE]`.

```python theme={null}
stream = client.chat.completions.create(
    model="openai/gpt-5.6-sol",
    messages=[{"role": "user", "content": "ping"}],
    stream=True,
    max_tokens=256,
)

for chunk in stream:
    delta = chunk.choices[0].delta.content
    if delta:
        print(delta, end="", flush=True)
```

## Responses API

If your SDK or app targets the OpenAI Responses API, keep the same base URL and key, but send Responses fields (`input`, `max_output_tokens`) instead of Chat Completions `messages` / `max_tokens`. See [Create response](/llm/responses).

## Related

* [LLM API guide](/llm/api) — protocols, auth, errors, and curl examples
* [Codex](/llm/codex) — CLI config with `openai_base_url`
* [OpenCode](/llm/opencode) — provider `baseURL` for OpenAI-compatible mode
