- Set the
OPENAI_BASE_URLandOPENAI_API_KEYenvironment variables - Use an open-source
modelsupported by Telnyx
export OPENAI_BASE_URL='https://api.telnyx.com/v2/ai'export OPENAI_API_KEY='KEY***'
OpenAI example
Chat Completions
// TODO: Re-add API reference link in navigation once Mintlify supports external links in nested groups.| Parameter | Description | Telnyx | OpenAI |
|---|---|---|---|
messages | Provides chat context | ✅ | ✅ |
model | Adjusts speed + quality | ✅ | ✅ |
stream | Streams response | ✅ | ✅ |
max_tokens | Limits output length | ✅ | ✅ |
temperature | Adjusts predictability | ✅ | ✅ |
top_p | Adjusts variety | ✅ | ✅ |
frequency_penalty | Decreases repetition | ✅ | ✅ |
presence_penalty | Decreases repetition… | ✅ | ✅ |
n | Returns n responses | ✅ | ✅ |
stop | Forces model to stop | ✅ | ✅ |
logit_bias | Tweaks odds of results | ✅ | ✅ |
logprobs | Returns odds of outputs | ✅ | ✅ |
top_logprobs | -> For how many candidates? | ✅ | ✅ |
seed | Reduces randomness | ✅ | ✅ |
response_format | Ensures syntax (e.g. JSON) | ✅ | ✅ |
tool_choice | How does model choose? | ✅ | ✅ |
tools | Helps model respond | ✅ | ✅ |
function | -> Outputs JSON for your code | ✅ | ✅ |
retrieval | -> Uses your docs (e.g. PDFs) | ✅ | ❌ |
guided_json | Ensures output conforms to schema | ✅ | ❌ |
guided_regex | Ensures output conforms to regex | ✅ | ❌ |
guided_choice | Ensures output conforms to choice | ✅ | ❌ |
min_p | top_p alternative | ✅ | ❌ |
use_beam_search | Explores more options | ✅ | ❌ |
best_of | -> How many options? | ✅ | ❌ |
length_penalty | -> Are long options bad? | ✅ | ❌ |
early_stopping | -> How hard should it try? | ✅ | ❌ |
user | Tracks users | ❌ | ✅ |
Transcriptions (BETA)
| Parameter | What does this do? | Telnyx | OpenAI |
|---|---|---|---|
file | Provides audio data | ✅ | ✅ |
model | Adjusts speed + quality | ✅ | ✅ |
response_format | Adjusts output format | ✅ | ✅ |
timestamp_granularities[] | Adds timestamps | ✅ | ✅ |
-> segment | -> per audio segment | ✅ | ✅ |
-> word | -> per word | ❌ | ✅ |
language | Improves accuracy | ❌ | ✅ |
prompt | Guides style | ❌ | ✅ |
temperature | Adjusts “creativity” | ❌ | ✅ |