Elastix Chat Completions API
Generate model completions for a chat conversation.
Generate model completions for a chat conversation.
Every API here is available over the APIs.io API and to AI agents over MCP.
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
find_apisBrowse and filter every API in the catalog.get_api_artifactsOne API's artifacts, grouped by type.get_openapiThe primary OpenAPI for this API.find_similar_apisAPIs that look like this one.apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.resolveTurn a domain, URL or GitHub org into the provider it belongs to.find_cohortsEvery scored population of providers in the catalog.curl "https://apis.io/api/v1/apis/elastix:elastix-chat-completions-api"
curl "https://apis.io/api/v1/apis?limit=25"
Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.
A second provider on the same verified email joins the account you already have.
openapi: 3.2.0
info:
title: Elastix Inference Chat API
version: 0.1.0
termsOfService: /legal/terms
contact:
name: Elastix
email: support@elastix.ai
description: 'Run chat completions on Elastix FPGA-accelerated inference over a simple HTTP API. It is **compatible with OpenAI''s Chat API**,
so you can reuse your existing OpenAI client libraries — just point them at our base URL. Learn more about Elastix at elastix.ai. ## OpenAI-Compatible Server
Use the API as a drop-in replacement for OpenAI — change only `base_url` and `api_key`. You can use any of OpenAI''s official SDKs and CLIs for `chat-completions` against Elastix:
```python
from openai import OpenAI
client = OpenAI(base_url="https://api.elastix.ai/v1", api_key="$ELASTIX_API_KEY")
resp = client.chat.completions.create(
model="elastix-default",
messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)
```
## Supported subset
We implement a **subset** of the OpenAI Chat Completions API, with the addition of an optional session_id (experimental). All other parameters might not be supported at this point. **Unknown parameters are ignored.**
The request fields we honor:
```typescript
type ChatCompletionRequest = {
model: string; // Model id — see GET /models
messages: Message[]; // The conversation so far
// Streaming
stream?: boolean; // Stream the reply as SSE. Default: false
stream_options?: { // Only valid with stream: true
include_usage?: boolean; // Emit a final chunk carrying token usage
};
// Length & sampling
max_tokens?: number; // Max tokens to generate. Range: [1, ∞)
temperature?: number; // Sampling temperature. Range: [0, ∞). Default: 1
top_p?: number; // Nucleus sampling mass. Range: (0, 1]. Default: 1
n?: number; // Number of completions to return. Range: [1, ∞). Default: 1
seed?: number; // Best-effort deterministic sampling
stop?: string | string[]; // Stop sequences
// Reasoning
reasoning_effort?: "low" | "medium" | "high"; // Only the GPT OSS models support this; others ignore if provided. Default: medium
// Repetition control
frequency_penalty?: number; // Penalize tokens by frequency. Range: [-2, 2]. Default: 0
presence_penalty?: number; // Penalize tokens already seen. Range: [-2, 2]. Default: 0
logit_bias?: Record; // Per-token-id bias. // Output format & introspection
response_format?: { type: "text" | "json_object" }; // Force plain text or JSON
logprobs?: boolean; // Return log-probs for output tokens. Default: false
top_logprobs?: number; // Top-N alternatives per position (0–20). Needs logprobs: true
// Tool calling — see the “Tool calling” section below
tools?: Tool[]; // Functions the model may call
tool_choice?: "none" | "auto" | "required" // Whether/which tool to call. Default: "auto" when tools are present
| { type: "function"; function: { name: string } };
parallel_tool_calls?: boolean; // Allow multiple tool calls in one turn. Default: "true" if the model supports it
// Routing (experimental — subject to change) — see the “Session stickiness” section below
metadata?: { // Arbitrary key/value metadata attached to the request
session_id?: string; // Stable conversation id; improves caching for multi-turn requests
};
};
type Message = {
// "developer" is an alias for "system" — both are treated identically. // A system/developer message is optional, but if present it must be first. // Use "tool" to return the result of a tool call back to the model. role: "system" | "developer" | "user" | "assistant" | "tool";
content: string | null; // Text only (image/audio not supported yet). // May be null on an assistant message that only calls tools. tool_calls?: ToolCall[]; // Present on an assistant message that calls tools
tool_call_id?: string; // Required on a "tool" message: which call this answers
};
type Tool = {
type: "function";
function: {
name: string; // ^[a-zA-Z0-9_-]+$
description: string; // Required (unlike OpenAI): what the tool does, so the model knows when to call it
parameters?: object; // JSON Schema object; omit for no-argument functions.'
x-scalar-sdk-installation:
- lang: cURL
description: "```sh\ncurl https://api.elastix.ai/v1/chat/completions \\\n -H \"Authorization: Bearer $ELASTIX_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"model\": \"elastix-default\",\n \"messages\": [{\"role\": \"user\", \"content\": \"Hello!\"}],\n \"metadata\": {\"session_id\": \"conv-abc-123\"}\n }'\n```"
- lang: Python
description: "```sh\npip install openai\n```\n\n```python\nfrom openai import OpenAI\n\nclient = OpenAI(base_url=\"https://api.elastix.ai/v1\", api_key=\"$ELASTIX_API_KEY\")\nresp = client.chat.completions.create(\n model=\"elastix-default\",\n messages=[{\"role\": \"user\", \"content\": \"Hello!\"}],\n)\nprint(resp.choices[0].message.content)\n```"
- lang: TypeScript
description: "```sh\nnpm install openai\n```\n\n```typescript\nimport OpenAI from \"openai\";\n\nconst client = new OpenAI({ baseURL: \"https://api.elastix.ai/v1\", apiKey: process.env.ELASTIX_API_KEY });\nconst resp = await client.chat.completions.create({\n model: \"elastix-default\",\n messages: [{ role: \"user\", content: \"Hello!\" }],\n});\nconsole.log(resp.choices[0].message.content);\n```"
- lang: Go
description: "```sh\ngo get github.com/openai/openai-go\n```\n\n```go\nclient := openai.NewClient(\n option.WithBaseURL(\"https://api.elastix.ai/v1\"),\n option.WithAPIKey(\"$ELASTIX_API_KEY\"),\n)\nresp, _ := client.Chat.Completions.New(context.TODO(), openai.ChatCompletionNewParams{\n Model: \"elastix-default\",\n Messages: []openai.ChatCompletionMessageParamUnion{openai.UserMessage(\"Hello!\")},\n})\nfmt.Println(resp.Choices[0].Message.Content)\n```"
- lang: C#
description: "```sh\ndotnet add package OpenAI\n```\n\n```csharp\nusing OpenAI;\nusing OpenAI.Chat;\nusing System.ClientModel;\n\nChatClient client = new(\n \"elastix-default\",\n new ApiKeyCredential(\"$ELASTIX_API_KEY\"),\n new OpenAIClientOptions { Endpoint = new Uri(\"https://api.elastix.ai/v1\") });\n\nChatCompletion completion = client.CompleteChat(\"Hello!\");\nConsole.WriteLine(completion.Content[0].Text);\n```"
- lang: Java
description: "```kotlin\nimplementation(\"com.openai:openai-java:4.0.0\")\n```\n\n```java\nOpenAIClient client = OpenAIOkHttpClient.builder()\n .baseUrl(\"https://api.elastix.ai/v1\")\n .apiKey(\"$ELASTIX_API_KEY\")\n .build();\n\nChatCompletionCreateParams params = ChatCompletionCreateParams.builder()\n .model(\"elastix-default\")\n .addUserMessage(\"Hello!\")\n .build();\n\nChatCompletion completion = client.chat().completions().create(params);\nSystem.out.println(completion.choices().get(0).message().content().orElse(\"\"));\n```"
- lang: Ruby
description: "```sh\ngem install openai\n```\n\n```ruby\nrequire \"openai\"\n\nclient = OpenAI::Client.new(api_key: \"$ELASTIX_API_KEY\", base_url: \"https://api.elastix.ai/v1\")\nchat = client.chat.completions.create(\n model: \"elastix-default\",\n messages: [{ role: \"user\", content: \"Hello!\" }],\n)\nputs chat.choices.first.message.content\n```"
- lang: CLI
description: "```sh\nbrew install openai/tools/openai\n```\n\n```sh\nexport OPENAI_BASE_URL=\"https://api.elastix.ai/v1\"\nexport OPENAI_API_KEY=\"$ELASTIX_API_KEY\"\n\nopenai api chat.completions.create \\\n -m elastix-default \\\n -g user \"Hello!\"\n```"
servers:
- url: https://api.elastix.ai
description: Production
security:
- bearerAuth: []
tags:
- name: Chat Completions
description: Generate model completions for a chat conversation.
paths:
/v1/chat/completions:
post:
tags:
- Chat Completions
operationId: createChatCompletion
summary: Create chat completion
description: 'Generates a model response for the given conversation.
Set `stream: true` to receive the response incrementally as
server-sent events.
Each event''s `data:` is a `ChatCompletionChunk`; the stream is
terminated by a final `data: [DONE]` line.'
x-codeSamples:
- lang: cURL
label: cURL
source: "curl https://api.elastix.ai/v1/chat/completions \\\n -H \"Authorization: Bearer $ELASTIX_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"model\": \"elastix-default\",\n \"messages\": [{\"role\": \"user\", \"content\": \"Hello!\"}],\n \"metadata\": {\"session_id\": \"conv-abc-123\"}\n }'"
- lang: Python
label: Python
source: "from openai import OpenAI\n\nclient = OpenAI(base_url=\"https://api.elastix.ai/v1\", api_key=\"$ELASTIX_API_KEY\")\nresp = client.chat.completions.create(\n model=\"elastix-default\",\n messages=[{\"role\": \"user\", \"content\": \"Hello!\"}],\n)\nprint(resp.choices[0].message.content)"
- lang: TypeScript
label: TypeScript
source: "import OpenAI from \"openai\";\n\nconst client = new OpenAI({ baseURL: \"https://api.elastix.ai/v1\", apiKey: process.env.ELASTIX_API_KEY });\nconst resp = await client.chat.completions.create({\n model: \"elastix-default\",\n messages: [{ role: \"user\", content: \"Hello!\" }],\n});\nconsole.log(resp.choices[0].message.content);"
- lang: Go
label: Go
source: "client := openai.NewClient(\n option.WithBaseURL(\"https://api.elastix.ai/v1\"),\n option.WithAPIKey(\"$ELASTIX_API_KEY\"),\n)\nresp, _ := client.Chat.Completions.New(context.TODO(), openai.ChatCompletionNewParams{\n Model: \"elastix-default\",\n Messages: []openai.ChatCompletionMessageParamUnion{openai.UserMessage(\"Hello!\")},\n})\nfmt.Println(resp.Choices[0].Message.Content)"
- lang: C#
label: C#
source: "using OpenAI;\nusing OpenAI.Chat;\nusing System.ClientModel;\n\nChatClient client = new(\n \"elastix-default\",\n new ApiKeyCredential(\"$ELASTIX_API_KEY\"),\n new OpenAIClientOptions { Endpoint = new Uri(\"https://api.elastix.ai/v1\") });\n\nChatCompletion completion = client.CompleteChat(\"Hello!\");\nConsole.WriteLine(completion.Content[0].Text);"
- lang: Java
label: Java
source: "OpenAIClient client = OpenAIOkHttpClient.builder()\n .baseUrl(\"https://api.elastix.ai/v1\")\n .apiKey(\"$ELASTIX_API_KEY\")\n .build();\n\nChatCompletionCreateParams params = ChatCompletionCreateParams.builder()\n .model(\"elastix-default\")\n .addUserMessage(\"Hello!\")\n .build();\n\nChatCompletion completion = client.chat().completions().create(params);\nSystem.out.println(completion.choices().get(0).message().content().orElse(\"\"));"
- lang: Ruby
label: Ruby
source: "require \"openai\"\n\nclient = OpenAI::Client.new(api_key: \"$ELASTIX_API_KEY\", base_url: \"https://api.elastix.ai/v1\")\nchat = client.chat.completions.create(\n model: \"elastix-default\",\n messages: [{ role: \"user\", content: \"Hello!\" }],\n)\nputs chat.choices.first.message.content"
- lang: CLI
label: CLI
source: "export OPENAI_BASE_URL=\"https://api.elastix.ai/v1\"\nexport OPENAI_API_KEY=\"$ELASTIX_API_KEY\"\n\nopenai api chat.completions.create \\\n -m elastix-default \\\n -g user \"Hello!\""
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateChatCompletionRequest'
example:
model: elastix-default
messages:
- role: system
content: You are a helpful assistant.
- role: user
content: Say hello in one sentence.
responses:
'200':
description: 'A chat completion. When `stream` is `false` the body is a single `ChatCompletion` JSON object; when `true` it is a `text/event-stream` of `ChatCompletionChunk` events ending with `data: [DONE]`.'
content:
application/json:
schema:
$ref: '#/components/schemas/ChatCompletion'
example:
id: chatcmpl-abc123
object: chat.completion
created: 1716000000
model: elastix-default
choices:
- index: 0
message:
role: assistant
content: Hello! How can I help you today?
finish_reason: stop
usage:
prompt_tokens: 19
completion_tokens: 9
total_tokens: 28
text/event-stream:
schema:
$ref: '#/components/schemas/ChatCompletionChunk'
'400':
description: Malformed request (invalid JSON, no messages, or unknown model).
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
message: Invalid model name passed in model=gpt-4o. Call GET /models to see the models available to your key.
type: invalid_request_error
param: model
code: '400'
'401':
description: Missing or invalid API key.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
message: 'Authentication error: no valid API key provided. Pass your key as a bearer token, e.g. ''Authorization: Bearer $ELASTIX_API_KEY''.'
type: authentication_error
param: key
code: '401'
'429':
description: Rate limit exceeded. Retry after the interval in the `Retry-After` header.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
message: 'Rate limit exceeded: too many requests. Retry after the number of seconds given in the Retry-After header, or reduce your request rate.'
type: rate_limit_error
param: null
code: '429'
components:
schemas:
CreateChatCompletionRequest:
type: object
required:
- model
- messages
properties:
model:
type: string
description: ID of the model to use. See the `/models` endpoint.
examples:
- elastix-default
messages:
type: array
minItems: 1
items:
$ref: '#/components/schemas/ChatMessage'
description: The conversation so far, in order.
stream:
type: boolean
default: false
description: If true, stream the response as server-sent events.
max_tokens:
type:
- integer
- 'null'
minimum: 1
description: Maximum number of tokens to generate in the completion.
temperature:
type: number
minimum: 0
default: 1
description: Sampling temperature. Higher is more random.
top_p:
type: number
exclusiveMinimum: 0
maximum: 1
default: 1
description: Nucleus sampling probability mass.
stop:
description: Sequences where generation stops. String or array of strings.
anyOf:
- type: string
- type: array
items:
type: string
- type: 'null'
n:
type: integer
minimum: 1
default: 1
description: How many chat completion choices to generate for each input.
seed:
type:
- integer
- 'null'
description: If set, sampling is made best-effort deterministic so repeated requests with the same seed and parameters return similar results.
reasoning_effort:
type: string
enum:
- low
- medium
- high
default: medium
description: How hard a reasoning model should think before answering. Only the GPT OSS models support this field; other models ignore it if provided.
frequency_penalty:
type: number
minimum: -2
maximum: 2
default: 0
description: Penalize new tokens by their existing frequency in the text so far, decreasing verbatim repetition.
presence_penalty:
type: number
minimum: -2
maximum: 2
default: 0
description: Penalize new tokens that already appear in the text so far, encouraging the model to talk about new topics.
logit_bias:
type:
- object
- 'null'
additionalProperties:
type: number
description: Map of token id to bias value added to the logits before sampling.
response_format:
type:
- object
- 'null'
properties:
type:
type: string
enum:
- text
- json_object
default: text
description: '`json_object` constrains the model to emit valid JSON.'
description: Controls the format of the model's output.
logprobs:
type: boolean
default: false
description: Whether to return log probabilities of the output tokens.
top_logprobs:
type:
- integer
- 'null'
minimum: 0
maximum: 20
description: Number of most likely tokens to return at each position, each with its log probability. Requires `logprobs` to be true.
stream_options:
type:
- object
- 'null'
properties:
include_usage:
type: boolean
description: If true, a final SSE chunk before `[DONE]` carries token usage.
description: Options for streaming responses. Only used when `stream` is true.
tools:
type: array
items:
$ref: '#/components/schemas/Tool'
description: A list of functions the model may call. The model returns the calls it wants to make in the response; your application executes them and sends the results back as `"tool"` messages.
tool_choice:
description: Controls whether and which tool the model calls. `"none"` disables tools, `"auto"` (the default when `tools` are present) lets the model decide, `"required"` forces at least one call, and an object forces a specific function.
anyOf:
- type: string
enum:
- none
- auto
- required
- $ref: '#/components/schemas/ToolChoiceFunction'
parallel_tool_calls:
type: boolean
default: true
description: Whether the model may request multiple tool calls in a single turn. Set to false to allow at most one.
metadata:
type:
- object
- 'null'
properties:
session_id:
type: string
description: '**Experimental — subject to change.** Stable conversation id used to optimize multi-turn routing: requests that share a session_id are routed on a best-effort basis to the server that served the previous turn to optimize prompt caching. This is used as an additional signal to content based routing.'
examples:
- conv-abc-123
description: Arbitrary key/value metadata attached to the request. Currently used for session stickiness via `session_id` (experimental).
ToolChoiceFunction:
type: object
required:
- type
- function
description: Forces the model to call a specific function.
properties:
type:
type: string
const: function
function:
type: object
required:
- name
properties:
name:
type: string
examples:
- get_weather
ChatCompletionChunk:
type: object
description: 'A single streamed chunk. The terminal event is the literal `data: [DONE]`.'
required:
- id
- object
- created
- model
- choices
properties:
id:
type: string
examples:
- chatcmpl-abc123
object:
type: string
const: chat.completion.chunk
created:
type: integer
model:
type: string
choices:
type: array
items:
type: object
required:
- index
- delta
properties:
index:
type: integer
delta:
type: object
properties:
role:
type: string
enum:
- assistant
content:
type:
- string
- 'null'
tool_calls:
type: array
description: Streamed tool-call fragments. Each item carries an `index` tying it to a call across chunks; `function.arguments` is a string fragment you concatenate by index. `id` and `function.name` appear on the first fragment for each call.
items:
type: object
required:
- index
properties:
index:
type: integer
id:
type: string
examples:
- call_abc123
type:
type: string
const: function
function:
type: object
properties:
name:
type: string
examples:
- get_weather
arguments:
type: string
examples:
- '{"city":"Paris"}'
finish_reason:
type:
- string
- 'null'
enum:
- stop
- length
- tool_calls
- null
usage:
description: Token usage, on the final chunk only, when `stream_options.include_usage` is true.
anyOf:
- $ref: '#/components/schemas/Usage'
- type: 'null'
Error:
type: object
required:
- error
description: OpenAI-compatible error envelope. The `error` object carries a human-readable `message` plus machine-readable fields for handling.
properties:
error:
type: object
required:
- message
properties:
message:
type: string
description: A human-readable explanation of what went wrong.
type:
type:
- string
- 'null'
description: The category of error, e.g. invalid_request_error, authentication_error, or rate_limit_error.
param:
type:
- string
- 'null'
description: The request parameter the error relates to, or null when not tied to a specific field.
code:
type:
- string
- 'null'
description: A short error code; mirrors the HTTP status.
ChatCompletion:
type: object
required:
- id
- object
- created
- model
- choices
properties:
id:
type: string
examples:
- chatcmpl-abc123
object:
type: string
const: chat.completion
created:
type: integer
description: Unix timestamp (seconds).
model:
type: string
choices:
type: array
items:
type: object
required:
- index
- message
- finish_reason
properties:
index:
type: integer
message:
$ref: '#/components/schemas/ChatMessage'
finish_reason:
type:
- string
- 'null'
enum:
- stop
- length
- tool_calls
- null
description: Why generation stopped. `tool_calls` means the model wants to call one or more tools (see `message.tool_calls`).
usage:
$ref: '#/components/schemas/Usage'
ToolCall:
type: object
required:
- id
- type
- function
description: A tool call requested by the model.
properties:
id:
type: string
description: Identifier for this call. Echo it back as `tool_call_id` on the `"tool"` message that carries the result.
examples:
- call_abc123
type:
type: string
const: function
function:
type: object
required:
- name
- arguments
properties:
name:
type: string
examples:
- get_weather
arguments:
type: string
description: The call arguments as a JSON-encoded string (not a JSON object). Parse it before use; the model may occasionally emit invalid JSON.
examples:
- '{"city":"Paris"}'
ChatMessage:
type: object
required:
- role
- content
properties:
role:
type: string
enum:
- system
- developer
- user
- assistant
- tool
description: The author of the message. `"developer"` is an alias for `"system"` and is treated identically. A system/developer message is optional, but if present it must be the first message in the array. Use `"tool"` to return the result of a tool call back to the model.
content:
type:
- string
- 'null'
description: The message text. Text only — image (vision) and audio content are not supported yet (both planned). May be `null` on an assistant message that only requests tool calls (see `tool_calls`).
tool_calls:
type: array
description: Tool calls the model wants to make. Present only on an assistant message; when set, `content` is typically `null`.
items:
$ref: '#/components/schemas/ToolCall'
tool_call_id:
type: string
description: 'Required on a `"tool"` message: the `id` of the tool call this message provides the result for.'
Tool:
type: object
required:
- type
- function
description: A function the model may call.
properties:
type:
type: string
const: function
description: The tool type. Only `function` is supported.
function:
type: object
required:
- name
- description
properties:
name:
type: string
description: The function name. Must match `^[a-zA-Z0-9_-]+$`; this is the name the model returns when it calls the tool.
examples:
- get_weather
description:
type: string
description: What the function does. The model uses this to decide when and how to call it, so make it descriptive. **Required** — unlike the OpenAI spec, our backend rejects a tool with no description.
parameters:
type: object
description: 'The function''s parameters as a JSON Schema object — see [OpenAI''s function calling guide](https://developers.openai.com/api/docs/guides/function-calling). Optional: for a function that takes no arguments, omit it or pass an empty schema `{ "type": "object", "properties": {} }`.'
Usage:
type: object
properties:
prompt_tokens:
type: integer
completion_tokens:
type: integer
total_tokens:
type: integer
securitySchemes:
bearerAuth:
type: http
scheme: bearer
description: 'Your Elastix API key, sent as `Authorization: Bearer <key>`.'
externalDocs:
description: Elastix - home
url: https://elastix.ai