https://api.telnyx.com/v2/ai/openai.
Prerequisites
- A Telnyx account.
- An API v2 key from API Keys in Mission Control Portal. See Create and manage API keys for key setup.
- cURL for the shell example, or Python 3.10+ for the Python example.
1. Set your API key
Replace the placeholder with the Telnyx API key. Run this in the same terminal used for the requests below:2. Send a chat completion
These examples usezai-org/GLM-5.3-Flash. See Available Models for model IDs and capabilities, or list models through the API.
- cURL
- Python
Run this in a macOS or Linux shell. No SDK installation is required:A successful request returns JSON with the answer in
choices[0].message.content. The usage object reports token counts. The answer text varies between requests./openai; the full HTTP endpoint ends in /openai/chat/completions. See the Chat Completions API reference for all request parameters and response fields.
3. Stream the response (optional)
Inquickstart.py, keep the imports and client setup, then replace the request and final print with this code. Run python quickstart.py again:
Reasoning models can return
reasoning_content separately from the final answer
in content: on message for a non-streaming response, or delta when streaming.
Models without reasoning omit this field. The example prints both separately so
the reasoning phase does not appear silent. Omit the reasoning print block to
display only the answer in an application.reasoning_effort only to a value supported by the selected model; unsupported values return an error.
Troubleshooting
Continue the conversation
Send prior turns inmessages to preserve context. Use system for model instructions, user for input, assistant for previous responses, and tool for function results. See Function Calling to connect the model to application code.