API Reference
Chat and Text Completions
Generate text with Chat Completions and Completions.
Chat Completions is the recommended text generation API. It supports multi-turn messages, streaming, tool calls, multimodal input and structured output. The legacy Text Completions API remains available for compatibility.
Endpoints
| Method | Path | Description |
|---|---|---|
POST | /v1/chat/completions | OpenAI-compatible chat completions |
POST | /v1/completions | Legacy text completions using prompt |
Request Fields
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model ID |
messages | array | Required for Chat | Conversation messages. FIM models may use prefix / suffix instead |
prompt | string or array | Required for Completions | Legacy text completion input |
stream | boolean | No | Return an SSE stream |
stream_options | object | No | Streaming options |
max_tokens | integer | No | Maximum output tokens |
max_completion_tokens | integer | No | Newer maximum output tokens field |
temperature, top_p, top_k | number | No | Sampling controls |
stop | string or array | No | Stop sequence |
tools, tool_choice | array/object | No | Tool calling configuration |
parallel_tool_calls | boolean | No | Allow parallel tool calls |
response_format | object | No | Structured output such as JSON object or JSON schema |
reasoning_effort | string | No | Reasoning effort for reasoning models |
modalities, audio | object | No | Multimodal or audio model parameters |
metadata | object | No | Pass-through metadata |
store, service_tier, safety_identifier | any | No | OpenAI extension fields; channel settings may filter them |
curl
curl https://api.tensoraxis.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TENSORAXIS_API_KEY" \
-d '{
"model": "gpt-4o",
"messages": [
{"role": "system", "content": "You are a concise assistant."},
{"role": "user", "content": "Describe TENSORAXIS in one sentence"}
],
"temperature": 0.7
}'Python
from openai import OpenAI
client = OpenAI(
api_key="your-tensoraxis-api-key",
base_url="https://api.tensoraxis.com/v1",
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)TypeScript
import OpenAI from 'openai'
const client = new OpenAI({
apiKey: process.env.TENSORAXIS_API_KEY,
baseURL: 'https://api.tensoraxis.com/v1',
})
const response = await client.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Hello!' }],
})
console.log(response.choices[0].message.content)Streaming
{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Write a three-line poem"}],
"stream": true
}With stream enabled, the response is SSE. Clients should read data: events until the stream finishes.
Multimodal Input
messages[].content can be a string or an array of content parts. The backend recognizes text, image_url, input_audio and related content types; actual support depends on the selected model and upstream channel.