Skip to Content
API/completions

/completions

Creates a completion for the provided prompt. This endpoint is compatible with the OpenAI Completions API.

Endpoint

POST /v1/completions

Headers

NameTypeDescription
AuthorizationstringRequired. Your API key prefixed with “Bearer “

Request Body

{ // ID of the model to use. Required. "model": string, // The prompt to generate completions for. Required. "prompt": string, // Whether to stream the response. Optional. "stream": boolean, // The maximum number of tokens to generate. Optional. "max_tokens": number, // Sampling temperature between 0 and 2. Optional. "temperature": number, // Alternative to temperature. Optional. "top_p": number }

Response

Returns a completion object:

{ "id": string, "object": "text_completion", "created": number, "model": string, "choices": [ { "text": string, "index": number, "finish_reason": string } ], "usage": { "prompt_tokens": number, "completion_tokens": number, "total_tokens": number } }

When stream is true, the response is sent as server-sent events in the same format.

Error Codes

  • 400 - Invalid request (missing required fields or invalid model)
  • 401 - Invalid API key
  • 429 - Rate limit exceeded or insufficient credit
  • 500 - Server error

Example

curl -X POST https://api.octora.io/v1/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_KEY" \ -d '{ "model": "gpt-4o", "prompt": "Write a haiku about programming", "max_tokens": 1000 }'