Skip to content

Text Completions

Generate text completions from a prompt.

Endpoint: POST /api/v1/completions
Auth: Required

Request Body

Field Type Required Default Description
prompt string Yes The text prompt to complete
model string No Model ID (e.g. openai/gpt-4o-mini)
provider string No Provider name
temperature float No Sampling temperature
max_tokens integer No Max tokens in response
top_p float No Nucleus sampling
frequency_penalty float No Frequency penalty
presence_penalty float No Presence penalty
stream boolean No false Enable streaming
additional_params object No {} Provider-specific parameters
byok_api_key string No Your own provider API key

Examples

import requests

response = requests.post(
    "https://api.indoxhub.com/api/v1/completions",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={
        "model": "openai/gpt-4o-mini",
        "prompt": "Write a haiku about programming:",
        "temperature": 0.8,
        "max_tokens": 100
    }
)
print(response.json()["data"])
const response = await fetch("https://api.indoxhub.com/api/v1/completions", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    model: "openai/gpt-4o-mini",
    prompt: "Write a haiku about programming:",
    temperature: 0.8,
    max_tokens: 100
  })
});
const data = await response.json();
console.log(data.data);
curl https://api.indoxhub.com/api/v1/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4o-mini",
    "prompt": "Write a haiku about programming:",
    "temperature": 0.8,
    "max_tokens": 100
  }'
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.indoxhub.com/v1"
)
response = client.completions.create(
    model="openai/gpt-4o-mini",
    prompt="Write a haiku about programming:",
    temperature=0.8,
    max_tokens=100
)
print(response.choices[0].text)

Response

{
  "request_id": "550e8400-e29b-41d4-a716-446655440000",
  "created_at": "2026-04-07T12:00:00Z",
  "duration_ms": 450.2,
  "provider": "openai",
  "model": "gpt-4o-mini",
  "success": true,
  "message": "",
  "data": "Semicolons fall\nLike rain upon the screen glow\nBugs hide in the night",
  "finish_reason": "stop",
  "usage": {
    "tokens_prompt": 8,
    "tokens_completion": 18,
    "tokens_total": 26,
    "cost": 0.0008,
    "latency": 450.2
  }
}

Stop Stream

Cancel an in-progress stream.

Endpoint: POST /api/v1/completions/stop-stream/{stream_id}

curl -X POST https://api.indoxhub.com/api/v1/completions/stop-stream/my-stream-id \
  -H "Authorization: Bearer YOUR_API_KEY"

Response:

{
  "success": true
}
Documentation last built on May 23, 2026