> ## 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.

# Switch from OpenAI in 2 lines

> Drop-in example showing the exact base URL and API key swap to call Corvex public endpoints using the official OpenAI Python and Node SDKs.

If you already use the official OpenAI client, switching to Corvex is a
**two-line change**: set your Corvex virtual key as the API key and point the
base URL at Corvex. Everything else — request shape, response shape,
streaming, tools, models — stays the same.

<Tip>
  The examples below are copy-paste runnable: set `OPENAI_API_KEY` to your virtual
  key (`sk-corvex-...`) and the script makes one real `/v1/chat/completions` call
  against `https://api.tokenfactory.corvex.cloud`.
</Tip>

## The 2-line swap

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

  from openai import OpenAI

  client = OpenAI(
      api_key=os.environ["OPENAI_API_KEY"],
      base_url="https://api.tokenfactory.corvex.cloud/v1",
  )
  print(client.chat.completions.create(
      model="zai-org/GLM-5.2-FP8",
      messages=[{"role": "user", "content": "Hello, Corvex."}],
  ).choices[0].message.content)
  ```

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

  const client = new OpenAI({
    apiKey: process.env.OPENAI_API_KEY,
    baseURL: "https://api.tokenfactory.corvex.cloud/v1",
  });
  console.log((await client.chat.completions.create({
    model: "zai-org/GLM-5.2-FP8",
    messages: [{ role: "user", content: "Hello, Corvex." }],
  })).choices[0].message.content);
  ```
</CodeGroup>

The highlighted lines are the **only** difference from a stock OpenAI client
call. No new SDK, no custom auth header — Corvex uses `Authorization: Bearer`,
just like OpenAI.

## Run it

```bash theme={null}
# Python
pip install openai
export OPENAI_API_KEY=sk-corvex-your-virtual-key
python python.py

# Node (requires Node 18+ for native fetch + top-level await)
npm install openai
export OPENAI_API_KEY=sk-corvex-your-virtual-key
node node.mjs
```

A successful run prints the model's reply to stdout. Any non-200 response
throws — the OpenAI SDKs raise `APIError` (Python) or `OpenAI.APIError` (Node)
with the gateway's structured error body.

## Model naming

Corvex uses **bare lab-canonical Hugging Face repo ids** for every model
(e.g. `zai-org/GLM-5.2-FP8`, `moonshotai/Kimi-K2.7-Code`). There is no Corvex
prefix — just send the bare model id. Serving topology is handled
server-side; you never encode it in the request. List the models your virtual
key can access:

```bash theme={null}
curl https://api.tokenfactory.corvex.cloud/v1/models \
  -H "Authorization: Bearer sk-corvex-YOUR_VIRTUAL_KEY"
```

## What's next

* **[Quickstart →](/getting-started/quickstart)** — broader guide
  including the curl reference and authentication notes.
* **[Authentication →](/getting-started/authentication)** — how your
  virtual key works and where to create one.
* **[API Reference →](/api-reference/openapi)** — every endpoint,
  request/response schemas, and error codes.
