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

# OpenAI-compatible API

> Use OpenAI clients or direct HTTP requests with Tokenless routing modes.

Use the OpenAI-compatible base URL with a Tokenless API key:

```text theme={"dark"}
https://api.usetokenless.com/openai/v1
```

<Note>
  Tokenless preserves the OpenAI request and response formats for the routes
  below, while choosing the upstream model behind a routing mode such as
  `tokenless-pro`.
</Note>

## Use an OpenAI client

<CodeGroup>
  ```python Python theme={"dark"}
  from openai import OpenAI
  import os

  client = OpenAI(
      base_url="https://api.usetokenless.com/openai/v1",
      api_key=os.environ["TOKENLESS_API_KEY"],
  )

  response = client.chat.completions.create(
      model="tokenless-pro",
      messages=[{"role": "user", "content": "Hello"}],
  )

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

  ```ts Node.js theme={"dark"}
  import OpenAI from "openai";

  const client = new OpenAI({
    baseURL: "https://api.usetokenless.com/openai/v1",
    apiKey: process.env.TOKENLESS_API_KEY,
  });

  const response = await client.chat.completions.create({
    model: "tokenless-pro",
    messages: [{ role: "user", content: "Hello" }],
  });

  console.log(response.choices[0]?.message.content);
  ```

  ```sh cURL theme={"dark"}
  curl https://api.usetokenless.com/openai/v1/chat/completions \
    -H "Authorization: Bearer $TOKENLESS_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "tokenless-pro",
      "messages": [{"role": "user", "content": "Hello"}]
    }'
  ```
</CodeGroup>

## Use Codex with tkl

With the Tokenless CLI installed, sign in once and launch Codex through the
OpenAI-compatible route. No API key setup is required.

```sh theme={"dark"}
tkl login
tkl codex
```

For the full upstream specification, see the [OpenAI API
reference](https://developers.openai.com/api/reference/overview). Use these
pages for the Tokenless-compatible routes and routing behavior.
