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

MethodPathDescription
POST/v1/chat/completionsOpenAI-compatible chat completions
POST/v1/completionsLegacy text completions using prompt

Request Fields

FieldTypeRequiredDescription
modelstringYesModel ID
messagesarrayRequired for ChatConversation messages. FIM models may use prefix / suffix instead
promptstring or arrayRequired for CompletionsLegacy text completion input
streambooleanNoReturn an SSE stream
stream_optionsobjectNoStreaming options
max_tokensintegerNoMaximum output tokens
max_completion_tokensintegerNoNewer maximum output tokens field
temperature, top_p, top_knumberNoSampling controls
stopstring or arrayNoStop sequence
tools, tool_choicearray/objectNoTool calling configuration
parallel_tool_callsbooleanNoAllow parallel tool calls
response_formatobjectNoStructured output such as JSON object or JSON schema
reasoning_effortstringNoReasoning effort for reasoning models
modalities, audioobjectNoMultimodal or audio model parameters
metadataobjectNoPass-through metadata
store, service_tier, safety_identifieranyNoOpenAI 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.