Skip to main content
The /v1/chat/completions endpoint is Routeway’s primary text generation API. It is 100% compatible with the OpenAI Chat Completions API format, providing access to 200+ models from OpenAI, Anthropic, Google, DeepSeek, xAI, Mistral, and more using a single API key and base URL.

Quickstart


Request Parameters


Messages & Roles

Every request is structured around an ordered messages array:

Roles

  • system: Sets global rules, tone, and constraints for the model. Put this first.
  • user: The end-user prompt or instruction. Can be a string or a rich content array containing images and PDFs.
  • assistant: The model’s reply from prior turns.

Multi-turn Conversations

Language models are stateless. To maintain conversation context, append each assistant response and subsequent user message to the array:

Response Object

A standard successful completion returns:

finish_reason Values


Tokens & Context Windows

Every request is measured in tokens (roughly 4 characters of English text):
  • prompt_tokens: Tokens in your messages array, system instructions, and schemas.
  • completion_tokens: Tokens generated by the model.
  • Context Window: Maximum sum of prompt + completion tokens allowed in a single request (e.g. 128k for GPT-4o, 200k for Claude 3.5, 1M+ for Gemini).

Managing Context Limits

When conversations grow long:
  1. Sliding Window: Retain the system message and only the last NN turns.
  2. Conversation Summarization: Periodically summarize older messages into an assistant summary block.
  3. Prompt Caching: Take advantage of Prompt Caching to dramatically cut cost and latency for repetitive system prompts and long reference material.

Advanced Capabilities

Explore specific features built on Chat Completions:

Server Tools (@online, @flux)

Search the web or generate images directly in chat by appending @online or @flux-2-turbo to model names.

Streaming

Receive tokens in real time using Server-Sent Events (SSE).

Tool Calling

Provide custom functions and schemas for models to execute.

Structured Outputs

Guarantee response conformity with JSON Schema validation.

Reasoning Models

Configure thinking budgets and effort levels for DeepSeek R1, OpenAI o-series, and Claude reasoning.

Multimodal Inputs

Pass images, charts, and PDF documents directly in message arrays.