Skip to main content
POST
/
v1
/
chat
/
completions
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.routeway.ai/v1",
    api_key=os.getenv("Routeway_API_KEY")
)

response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[
        {"role": "user", "content": "Write a short story about a robot and a cat."}
    ]
)

print(response.choices[0].message.content)
{
  "id": "<string>",
  "created": 123,
  "model": "<string>",
  "choices": [
    {
      "index": 123,
      "message": {
        "role": "<string>",
        "content": "<string>",
        "refusal": "<string>",
        "tool_calls": [
          "<unknown>"
        ]
      },
      "finish_reason": "<string>",
      "logprobs": {}
    }
  ],
  "usage": {
    "prompt_tokens": 123,
    "completion_tokens": 123,
    "total_tokens": 123
  },
  "object": "chat.completion",
  "system_fingerprint": "<string>"
}
This API endpoint allows you to send text and images as inputs, and the model will generate the next message in the conversation.

Create Chat Completion

To create a chat completion, use the following endpoint: POST /v1/chat/completions

Request Body

model
string
required
The model id to use for completion (“gpt-4o”, “gpt-4o-mini”, “deepseek-r”, )
messages
array
required
An array of message objects that form the conversation
max_tokens
integer
The maximum number of tokens to generate
temperature
string
Sampling temperature, a value between 0 and 2.
stream
boolean
Whether to enable streaming responses
frequency_penalty
integer
Tells the model not to repeat a word that has already been used multiple times in the conversation.
presence_penalty
integer
Prevents the model from repeating a word, even if it’s only been used once
stop
array
Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.routeway.ai/v1",
    api_key=os.getenv("Routeway_API_KEY")
)

response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[
        {"role": "user", "content": "Write a short story about a robot and a cat."}
    ]
)

print(response.choices[0].message.content)

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Headers

x-api-key
string

Body

application/json
model
string
required
messages
ChatMessage · object[]
required
Minimum array length: 1
tools
Tool · object[] | null
tool_choice
functions
any[]
function_call
response_format
TextResponseFormat · object
temperature
number | null
Required range: 0 <= x <= 2
top_p
number | null
Required range: 0 <= x <= 1
stream
boolean | null
default:false
stream_options
StreamOptions · object
stop
max_tokens
integer | null
Required range: x >= 1
max_completion_tokens
integer | null
Required range: x >= 1
presence_penalty
number | null
Required range: -2 <= x <= 2
frequency_penalty
number | null
Required range: -2 <= x <= 2
logit_bias
Logit Bias · object
reasoning_effort
enum<string> | null
Available options:
none,
minimal,
low,
medium,
high,
xhigh

Response

Successful Response

id
string
required

A unique identifier for the chat completion.

created
integer
required

The Unix timestamp (in seconds) of when the chat completion was created.

model
string
required

The model used for the chat completion.

choices
ChatCompletionChoice · object[]
required

A list of chat completion choices.

usage
ChatCompletionUsage · object
required

Usage statistics for the completion request.

object
string
default:chat.completion

The object type, which is always chat.completion.

Allowed value: "chat.completion"
system_fingerprint
string | null

This fingerprint represents the backend configuration that the model runs with.