v1

latestOpenAPI 3.0.3MIT2026-07-132953108.7 KB
Text Completions

Create Text Completion

Creates a text completion from a prompt. Useful for text generation, summarization, and other non-conversational tasks.

post/v1/text/completions

Request body

modelstring required

Model identifier in 'provider/model' format (e.g., 'anthropic/claude-2.1')

textstring required

Text prompt for completion

max_tokensinteger

Maximum number of tokens to generate

temperaturenumber

Controls randomness in the output

stop_sequencesstring[]

Sequences that stop generation

fallbacksstring[]

Fallback model names in 'provider/model' format

Example request

{
  "model": "anthropic/claude-2.1",
  "text": "The benefits of artificial intelligence include",
  "max_tokens": 1000,
  "temperature": 0.7,
  "fallbacks": [
    "anthropic/claude-3-haiku-20240307",
    "openai/gpt-4o-mini"
  ]
}

Response

Successful text completion

idstring

Unique response identifier

object'chat.completion' | 'text.completion'

Response type

modelstring

Model used for generation

createdinteger

Unix timestamp of creation

service_tierstring

Service tier used

system_fingerprintstring

System fingerprint

Example response

{
  "id": "chatcmpl-123",
  "object": "chat.completion",
  "choices": [
    {
      "message": {
        "role": "user",
        "content": "Hello, how are you?",
        "tool_calls": [
          {
            "id": "tool_123",
            "type": "function",
            "function": {
              "name": "get_weather",
              "arguments": "{\"location\": \"San Francisco, CA\"}"
            }
          }
        ]
      },
      "finish_reason": "stop",
      "log_probs": {
        "content": [
          {
            "logprob": -0.123,
            "token": "hello",
            "top_logprobs": [
              {
                "logprob": -0.456,
                "token": "world"
              }
            ]
          }
        ],
        "refusal": [
          {
            "logprob": -0.456,
            "token": "world"
          }
        ]
      }
    }
  ],
  "model": "gpt-4o",
  "created": 1677652288,
  "usage": {
    "prompt_tokens": 56,
    "completion_tokens": 31,
    "total_tokens": 87
  },
  "extra_fields": {
    "provider": "openai",
    "model_params": {
      "temperature": 0.7,
      "top_p": 0.9,
      "top_k": 40,
      "max_tokens": 1000,
      "stop_sequences": [
        "\n\n",
        "END"
      ],
      "tools": [
        {
          "type": "function",
          "function": {
            "name": "get_weather",
            "description": "Get current weather for a location",
            "parameters": {
              "type": "object"
            }
          }
        }
      ],
      "tool_choice": {
        "type": "auto",
        "function": {
          "name": "get_weather"
        }
      },
      "parallel_tool_calls": true
    },
    "latency": 1.234,
    "chat_history": [
      {
        "role": "user",
        "content": "Hello, how are you?",
        "tool_calls": [
          {
            "id": "tool_123",
            "type": "function",
            "function": {
              "name": "get_weather",
              "arguments": "{\"location\": \"San Francisco, CA\"}"
            }
          }
        ]
      }
    ]
  }
}