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

# Use the OpenAI SDK

> Configure the official OpenAI Python or TypeScript SDK to call Corvex Token Factory.

Keep the official OpenAI client and Chat Completions request format. Change the
client's base URL and API key, then choose a model from the Token Factory
catalog. Model IDs and feature support differ from OpenAI's hosted models.

## Prerequisites

* A Token Factory API key. See [Authentication](https://docs.corvex.cloud/getting-started/authentication.md).
* Python with the `openai` package, or Node.js with the `openai` package.
* A model ID from the [live catalog](https://docs.corvex.cloud/models/overview.md).

Set the key in your shell:

```bash theme={null}
export CORVEX_API_KEY="sk-corvex-YOUR_VIRTUAL_KEY"
```

## Configure the client

```python python {6-7} theme={null}
import os

from openai import OpenAI

client = OpenAI(
    api_key=os.environ["CORVEX_API_KEY"],
    base_url="https://api.tokenfactory.corvex.cloud/v1",
)

response = client.chat.completions.create(
    model="zai-org/GLM-5.3",
    messages=[{"role": "user", "content": "Explain this function."}],
)
print(response.choices[0].message.content)
```

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

const client = new OpenAI({
  apiKey: process.env.CORVEX_API_KEY,
  baseURL: "https://api.tokenfactory.corvex.cloud/v1",
});

const response = await client.chat.completions.create({
  model: "zai-org/GLM-5.3",
  messages: [{ role: "user", content: "Explain this function." }],
});
console.log(response.choices[0].message.content);
```

The highlighted constructor fields route the client to Token Factory. Requests
use the standard Bearer header generated by the OpenAI SDK.

## Run the repository examples

```bash theme={null}
# Python
python -m pip install openai
python integrations/openai-drop-in/python.py

# Node.js
npm install openai
node integrations/openai-drop-in/node.mjs
```

A non-`2xx` response raises the SDK's API error type with the structured Token
Factory error body. Configure timeouts and retries through the SDK as you would
for any remote inference service.

## Model IDs

Token Factory model IDs use `namespace/model` format. List the public catalog
before hard-coding an ID:

```bash theme={null}
curl https://api.tokenfactory.corvex.cloud/v1/models
```

Do not add a `corvex/` prefix. The [model catalog](https://docs.corvex.cloud/models/overview.md) documents
input types, context windows, capabilities, and rates.

## Related documentation

* [Quickstart](https://docs.corvex.cloud/getting-started/quickstart.md) — test the endpoint with `curl`.
* [Errors](https://docs.corvex.cloud/reference/errors.md) — handle authentication, validation, rate-limit,
  and server failures.
* [API reference](https://docs.corvex.cloud/api-reference/openapi.md) — review the supported OpenAI-compatible
  request and response fields.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.