Skip to main content
POST
/
ai
/
openai
/
responses
JavaScript
import Telnyx from 'telnyx';

const client = new Telnyx({
  apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});

const response = await client.ai.openai.createResponse({
  conversation: '6a09cdc3-8948-47f0-aa62-74ac943d6c58',
  input: [{ role: 'user', content: [{ type: 'input_text', text: 'Hello, world!' }] }],
  instructions: 'You are a friendly chatbot.',
  model: 'zai-org/GLM-5.1-FP8',
  stream: true,
});

console.log(response);
import os
from telnyx import Telnyx

client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
response = client.ai.openai.create_response(
conversation="6a09cdc3-8948-47f0-aa62-74ac943d6c58",
input=[{
"role": "user",
"content": [{
"type": "input_text",
"text": "Hello, world!",
}],
}],
instructions="You are a friendly chatbot.",
model="zai-org/GLM-5.1-FP8",
stream=True,
)
print(response)
package main

import (
"context"
"fmt"

"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)

func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.AI.OpenAI.NewResponse(context.TODO(), telnyx.AIOpenAINewResponseParams{
Conversation: telnyx.String("6a09cdc3-8948-47f0-aa62-74ac943d6c58"),
Input: []any{
map[string]any{
"role": "user",
"content": []any{
map[string]any{
"type": "input_text",
"text": "Hello, world!",
},
},
},
},
Instructions: telnyx.String("You are a friendly chatbot."),
Model: telnyx.String("zai-org/GLM-5.1-FP8"),
Stream: telnyx.Bool(true),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response)
}
package com.telnyx.sdk.example;

import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.ai.openai.OpenAICreateResponseParams;
import com.telnyx.sdk.models.ai.openai.OpenAICreateResponseResponse;

public final class Main {
private Main() {}

public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();

OpenAICreateResponseResponse response = client.ai().openai().createResponse();
}
}
require "telnyx"

telnyx = Telnyx::Client.new(api_key: "My API Key")

response = telnyx.ai.openai.create_response

puts(response)
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;

$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');

try {
$response = $client->ai->openai->createResponse(
conversation: '6a09cdc3-8948-47f0-aa62-74ac943d6c58',
input: [
[
'role' => 'user',
'content' => [['type' => 'input_text', 'text' => 'Hello, world!']],
],
],
instructions: 'You are a friendly chatbot.',
model: 'zai-org/GLM-5.1-FP8',
stream: true,
);

var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}
telnyx ai:openai create-response \
--api-key 'My API Key'
curl --request POST \
--url https://api.telnyx.com/v2/ai/openai/responses \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "zai-org/GLM-5.1-FP8",
"conversation": "6a09cdc3-8948-47f0-aa62-74ac943d6c58",
"instructions": "You are a friendly chatbot.",
"input": [
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "Hello, world!"
}
]
}
],
"stream": true
}
'
{}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
model
string

Model identifier to use for the response, for example zai-org/GLM-5.1-FP8 or another model available from the Telnyx OpenAI-compatible models endpoint.

input
any

The input items for this turn, using the OpenAI Responses API input format.

conversation
string<uuid>

Optional Telnyx Conversation ID from POST /ai/conversations. When provided, Telnyx stores this turn on that conversation and uses the conversation's prior messages as context. Reuse the same ID for subsequent turns and tool-result followups. Omit it for a non-persisted, stateless response.

instructions
string

Optional system/developer instructions for the model. When used with a persisted conversation, send these on the first request that creates the thread; subsequent turns can rely on the stored history.

stream
boolean

Set to true to stream Server-Sent Events, matching OpenAI's Responses streaming format.

Response

Successful Response

The response is of type object.