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

# OpenAI API Migration Guide

> Migrate from the OpenAI API to the Telnyx Inference API by changing two environment variables and a model name — no code rewrites required.

Swap two environment variables and change the model name. That's it.

```shell theme={null}
export OPENAI_BASE_URL='https://api.telnyx.com/v2/ai/openai'
export OPENAI_API_KEY='KEY***'
```

```python theme={null}
from openai import OpenAI

client = OpenAI()  # picks up env vars
chat_completion = client.chat.completions.create(
    model="zai-org/GLM-5.1-FP8",
    messages=[{"role": "user", "content": "Tell me about Telnyx"}],
    temperature=0.0,
    stream=True,
)
```

Or pass explicitly:

```python theme={null}
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.getenv("TELNYX_API_KEY"),
    base_url="https://api.telnyx.com/v2/ai/openai",
)
chat_completion = client.chat.completions.create(
    model="zai-org/GLM-5.1-FP8",
    messages=[{"role": "user", "content": "Tell me about Telnyx"}],
    temperature=0.0,
    stream=True,
)
```

## Reasoning models

Reasoning models such as `zai-org/GLM-5.1-FP8` add a `reasoning_content` field alongside
the usual `content`. It holds the model's chain-of-thought and appears on `message`
(non-streaming) or `delta` (streaming). Read it the same way you read `content`:

```python theme={null}
chat_completion = client.chat.completions.create(
    model="zai-org/GLM-5.1-FP8",
    messages=[{"role": "user", "content": "Tell me about Telnyx"}],
)
message = chat_completion.choices[0].message

# Reasoning models populate reasoning_content; other models leave it None.
if getattr(message, "reasoning_content", None):
    print("reasoning:", message.reasoning_content)
print("answer:", message.content)
```

## Chat Completions Compatibility

| Parameter           | Telnyx | OpenAI |
| ------------------- | :----: | :----: |
| `messages`          |    ✅   |    ✅   |
| `model`             |    ✅   |    ✅   |
| `stream`            |    ✅   |    ✅   |
| `max_tokens`        |    ✅   |    ✅   |
| `temperature`       |    ✅   |    ✅   |
| `top_p`             |    ✅   |    ✅   |
| `frequency_penalty` |    ✅   |    ✅   |
| `presence_penalty`  |    ✅   |    ✅   |
| `n`                 |    ✅   |    ✅   |
| `stop`              |    ✅   |    ✅   |
| `logit_bias`        |    ✅   |    ✅   |
| `logprobs`          |    ✅   |    ✅   |
| `top_logprobs`      |    ✅   |    ✅   |
| `seed`              |    ✅   |    ✅   |
| `response_format`   |    ✅   |    ✅   |
| `tool_choice`       |    ✅   |    ✅   |
| `tools`             |    ✅   |    ✅   |
| `function`          |    ✅   |    ✅   |
| `retrieval`         |    ✅   |    ❌   |
| `guided_json`       |    ✅   |    ❌   |
| `guided_regex`      |    ✅   |    ❌   |
| `guided_choice`     |    ✅   |    ❌   |
| `min_p`             |    ✅   |    ❌   |
| `use_beam_search`   |    ✅   |    ❌   |
| `best_of`           |    ✅   |    ❌   |
| `length_penalty`    |    ✅   |    ❌   |
| `early_stopping`    |    ✅   |    ❌   |
| `user`              |    ❌   |    ✅   |

## Transcriptions Compatibility

| Parameter                               | Telnyx | OpenAI |
| --------------------------------------- | :----: | :----: |
| `file`                                  |    ✅   |    ✅   |
| `model`                                 |    ✅   |    ✅   |
| `response_format`                       |    ✅   |    ✅   |
| `timestamp_granularities[]` → `segment` |    ✅   |    ✅   |
| `timestamp_granularities[]` → `word`    |    ❌   |    ✅   |
| `language`                              |    ❌   |    ✅   |
| `prompt`                                |    ❌   |    ✅   |
| `temperature`                           |    ❌   |    ✅   |
