Skip to main content

Text Generation

Available Models

A full list of models can be viewed on the Models page or retrieved dynamically via API endpoints: https://openai.bothub.chat/v1/models and https://bothub.chat/api/v2/replicate/v1/models

For text processing, visual analysis, and much more, BotHub uses the OpenAI gateway. You can make requests via two different endpoints depending on your project architecture: the classic Chat Completions API or the modern Responses API.


Chat Completions API vs Responses API​

  • Chat Completions API — a classic endpoint built around the familiar role-based system (system, user, assistant). It is fully compatible with official OpenAI SDKs. A great choice for quick integration and standard chat interfaces.
  • Responses API — a new multimodal endpoint. It does not require official SDKs, supports both simple string input and complex data arrays, and allows for flexible control over response structure (JSON schemas) and tools.

1. Chat Completions API (Classic Gateway)​

This endpoint is fully compatible with OpenAI syntax. You can use official libraries by simply overriding baseURL to https://openai.bothub.chat/v1.

Synchronous Generation​

import OpenAI from 'openai';

const openai = new OpenAI({
apiKey: 'YOUR_BOTHUB_API_KEY',
baseURL: 'https://openai.bothub.chat/v1'
});

async function main() {
const completion = await openai.chat.completions.create({
model: 'claude-opus-5',
messages: [{ role: 'user', content: 'Hello! Tell me about yourself in three words.' }],
});

console.log(completion.choices[0].message.content);
}

main();

Streaming Generation​

import OpenAI from 'openai';

const openai = new OpenAI({
apiKey: 'YOUR_BOTHUB_API_KEY',
baseURL: 'https://openai.bothub.chat/v1'
});

async function main() {
const stream = await openai.chat.completions.create({
model: 'claude-opus-5',
messages: [{ role: 'user', content: 'Write a short story about AI.' }],
stream: true,
});

for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || '');
}
}

main();

Example of an OpenAI gateway response:​

{
"id": "gen-1779989130-XaEliNRQ9QbSu4dyJgr3",
"object": "chat.completion",
"created": 1779989130,
"model": "anthropic/claude-4.7-opus-fast-20260512",
"provider": "Anthropic",
"system_fingerprint": null,
"service_tier": "default",
"choices": [
{
"index": 0,
"logprobs": null,
"finish_reason": "stop",
"native_finish_reason": "end_turn",
"message": {
"role": "assistant",
"content": "AI assistant from Anthropic.",
"refusal": null,
"reasoning": null
}
}
],
"usage": {
"prompt_tokens": 29,
"completion_tokens": 19,
"total_tokens": 48,
"cost": 0.00372,
"is_byok": false,
"prompt_tokens_details": {
"cached_tokens": 0,
"cache_write_tokens": 0,
"audio_tokens": 0,
"video_tokens": 0
},
"cost_details": {
"upstream_inference_cost": 0.00372,
"upstream_inference_prompt_cost": 0.00087,
"upstream_inference_completions_cost": 0.00285
},
"completion_tokens_details": {
"reasoning_tokens": 0,
"image_tokens": 0,
"audio_tokens": 0
},
"speed": "fast"
}
}

2. Responses API (New Unified Gateway)​

This endpoint accepts requests at https://openai.bothub.chat/v1/responses directly via standard HTTP methods. It offers a simplified structure for plain text and advanced control for multi-turn dialogues.

Does not save state

Responses API Alpha does not store conversation history on the server. To maintain context, the client side must pass an array of all previous messages in the input property with each new request.


Option 1: Simple Text Input (String)​

async function sendRequest() {
const response = await fetch('https://openai.bothub.chat/v1/responses', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_BOTHUB_API_KEY'
},
body: JSON.stringify({
model: 'claude-opus-5',
input: 'What is the meaning of life?',
max_output_tokens: 4000
})
});

const result = await response.json();
console.log(result.output[0].content[0].text);
}

sendRequest();

Option 2: Structured Message Input​

Use for complex chats, pass the full chat history. When passing history from assistant, id and status fields are optional.

async function sendChat() {
const response = await fetch('https://openai.bothub.chat/v1/responses', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_BOTHUB_API_KEY'
},
body: JSON.stringify({
model: 'claude-opus-5',
input: [
{
type: 'message',
role: 'user',
content: [{ type: 'input_text', text: 'What is the capital of France?' }]
},
{
type: 'message',
id: 'msg_internal_123',
status: 'completed',
role: 'assistant',
content: [{ type: 'output_text', text: 'The capital of France is Paris.' }]
},
{
type: 'message',
role: 'user',
content: [{ type: 'input_text', text: 'What is its population?' }]
}
],
max_output_tokens: 4000
})
});

const result = await response.json();
console.log(result.output[0].content[0].text);
}

sendChat();

3. Vision (Image Analysis)​

Vision is the ability to send images along with a text prompt so the model can analyze visual content: recognize objects, describe scenes, analyze interfaces, and read text (OCR).

Supported Models​

Almost all modern multimodal models available in BotHub are suitable for image analysis:

  • OpenAI: the entire gpt-4o, gpt-4.1 lineup and the gpt-5 family
  • Anthropic Claude: current versions of claude-sonnet and claude-opus
  • Google Gemini: fast and advanced gemini models

And many other flagship and specialized models.

Image Submission Formats​

You can pass an image either as a public URL or as a Base64 encoded string.

Via URL

{
"type": "image_url",
"image_url": {
"url": "https://images.unsplash.com/photo-1579783902614-a3fb3927b6a5"
}
}

Via Base64

{
"type": "image_url",
"image_url": {
"url": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQ..."
}
}

Vision Request Example (Chat Completions API)​

import OpenAI from 'openai';

const openai = new OpenAI({
apiKey: 'YOUR_BOTHUB_API_KEY',
baseURL: 'https://openai.bothub.chat/v1'
});

async function main() {
const res = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
{
role: "user",
content: [
{ type: "text", text: "What is depicted in this photo?" },
{
type: "image_url",
image_url: {
url: "https://images.unsplash.com/photo-1579783902614-a3fb3927b6a5"
}
}
]
}
]
});

console.log(res.choices[0].message.content);
}

main();
Recommendations
  • For most Vision tasks, it is recommended to use gpt-4o, as the model provides the best balance between speed, quality, and cost.
  • If you need to work with long documents, complex diagrams, or large context, pay attention to Claude and Gemini models.
  • For local images, use Base64, and for publicly accessible files — use standard URLs.

4. Reasoning Effort​

Reasoning models can think more or less before they answer. BotHub accepts the same scale for every model: none, minimal, low, medium, high, xhigh, max.

GatewayParameter
Chat Completions APIreasoning_effort
Responses APIreasoning.effort
curl https://openai.bothub.chat/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_BOTHUB_API_KEY" \
-d '{
"model": "glm-5.2",
"reasoning_effort": "medium",
"messages": [{"role": "user", "content": "How many prime numbers are there below 100?"}]
}'

How the level is applied​

Each model supports its own part of the scale, and you do not have to keep track of it. If the model does not have the level you sent, the gateway applies the highest level of the model that does not exceed your request. If the model has nothing that low, its lowest level is applied.

You sendLevels of the modelApplied
low or mediumhigh, xhighhigh
maxhigh, xhighxhigh
xhighlow, medium, high, maxhigh
minimalnone, low, medium, highlow

none asks the model not to reason. Where reasoning cannot be switched off, the lowest level of the model is applied instead, and the request does not fail.

Which levels a model has​

Request GET https://bothub.chat/api/v2/model/list and find the model. Its apiParams array has an entry with the code reasoning_effort. In that entry enum lists the levels of the model, and default is the level preselected in the BotHub chat:

{
"code": "reasoning_effort",
"type": "string",
"enum": ["high", "xhigh"],
"default": "high"
}