curl --request POST \
--url https://models.relace.ai/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "deepseek-ai/DeepSeek-V4-Flash-0731",
"messages": [
{
"role": "user",
"content": "Write a binary search in Python."
}
],
"stream": false
}
'import requests
url = "https://models.relace.ai/v1/chat/completions"
payload = {
"model": "deepseek-ai/DeepSeek-V4-Flash-0731",
"messages": [
{
"role": "user",
"content": "Write a binary search in Python."
}
],
"stream": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'deepseek-ai/DeepSeek-V4-Flash-0731',
messages: [{role: 'user', content: 'Write a binary search in Python.'}],
stream: false
})
};
fetch('https://models.relace.ai/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://models.relace.ai/v1/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'deepseek-ai/DeepSeek-V4-Flash-0731',
'messages' => [
[
'role' => 'user',
'content' => 'Write a binary search in Python.'
]
],
'stream' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://models.relace.ai/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"deepseek-ai/DeepSeek-V4-Flash-0731\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Write a binary search in Python.\"\n }\n ],\n \"stream\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://models.relace.ai/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"deepseek-ai/DeepSeek-V4-Flash-0731\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Write a binary search in Python.\"\n }\n ],\n \"stream\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://models.relace.ai/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"deepseek-ai/DeepSeek-V4-Flash-0731\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Write a binary search in Python.\"\n }\n ],\n \"stream\": false\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "<string>",
"created": 123,
"model": "<string>",
"choices": [
{
"index": 123,
"message": {},
"finish_reason": "<string>"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
}
}{
"error": {
"message": "Rate limit exceeded. Retry after the Retry-After interval, or contact support to raise your limits.",
"type": "rate_limit_error",
"param": null,
"code": null
}
}{
"error": {
"message": "Rate limit exceeded. Retry after the Retry-After interval, or contact support to raise your limits.",
"type": "rate_limit_error",
"param": null,
"code": null
}
}{
"error": {
"message": "Rate limit exceeded. Retry after the Retry-After interval, or contact support to raise your limits.",
"type": "rate_limit_error",
"param": null,
"code": null
}
}{
"error": {
"message": "Rate limit exceeded. Retry after the Retry-After interval, or contact support to raise your limits.",
"type": "rate_limit_error",
"param": null,
"code": null
}
}{
"error": {
"message": "Rate limit exceeded. Retry after the Retry-After interval, or contact support to raise your limits.",
"type": "rate_limit_error",
"param": null,
"code": null
}
}{
"error": {
"message": "Rate limit exceeded. Retry after the Retry-After interval, or contact support to raise your limits.",
"type": "rate_limit_error",
"param": null,
"code": null
}
}{
"error": {
"message": "Rate limit exceeded. Retry after the Retry-After interval, or contact support to raise your limits.",
"type": "rate_limit_error",
"param": null,
"code": null
}
}{
"error": {
"message": "Rate limit exceeded. Retry after the Retry-After interval, or contact support to raise your limits.",
"type": "rate_limit_error",
"param": null,
"code": null
}
}{
"error": {
"message": "Rate limit exceeded. Retry after the Retry-After interval, or contact support to raise your limits.",
"type": "rate_limit_error",
"param": null,
"code": null
}
}Chat Completions
Send an OpenAI-compatible chat completions request to a Relace-hosted model.
curl --request POST \
--url https://models.relace.ai/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "deepseek-ai/DeepSeek-V4-Flash-0731",
"messages": [
{
"role": "user",
"content": "Write a binary search in Python."
}
],
"stream": false
}
'import requests
url = "https://models.relace.ai/v1/chat/completions"
payload = {
"model": "deepseek-ai/DeepSeek-V4-Flash-0731",
"messages": [
{
"role": "user",
"content": "Write a binary search in Python."
}
],
"stream": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'deepseek-ai/DeepSeek-V4-Flash-0731',
messages: [{role: 'user', content: 'Write a binary search in Python.'}],
stream: false
})
};
fetch('https://models.relace.ai/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://models.relace.ai/v1/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'deepseek-ai/DeepSeek-V4-Flash-0731',
'messages' => [
[
'role' => 'user',
'content' => 'Write a binary search in Python.'
]
],
'stream' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://models.relace.ai/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"deepseek-ai/DeepSeek-V4-Flash-0731\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Write a binary search in Python.\"\n }\n ],\n \"stream\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://models.relace.ai/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"deepseek-ai/DeepSeek-V4-Flash-0731\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Write a binary search in Python.\"\n }\n ],\n \"stream\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://models.relace.ai/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"deepseek-ai/DeepSeek-V4-Flash-0731\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Write a binary search in Python.\"\n }\n ],\n \"stream\": false\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "<string>",
"created": 123,
"model": "<string>",
"choices": [
{
"index": 123,
"message": {},
"finish_reason": "<string>"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
}
}{
"error": {
"message": "Rate limit exceeded. Retry after the Retry-After interval, or contact support to raise your limits.",
"type": "rate_limit_error",
"param": null,
"code": null
}
}{
"error": {
"message": "Rate limit exceeded. Retry after the Retry-After interval, or contact support to raise your limits.",
"type": "rate_limit_error",
"param": null,
"code": null
}
}{
"error": {
"message": "Rate limit exceeded. Retry after the Retry-After interval, or contact support to raise your limits.",
"type": "rate_limit_error",
"param": null,
"code": null
}
}{
"error": {
"message": "Rate limit exceeded. Retry after the Retry-After interval, or contact support to raise your limits.",
"type": "rate_limit_error",
"param": null,
"code": null
}
}{
"error": {
"message": "Rate limit exceeded. Retry after the Retry-After interval, or contact support to raise your limits.",
"type": "rate_limit_error",
"param": null,
"code": null
}
}{
"error": {
"message": "Rate limit exceeded. Retry after the Retry-After interval, or contact support to raise your limits.",
"type": "rate_limit_error",
"param": null,
"code": null
}
}{
"error": {
"message": "Rate limit exceeded. Retry after the Retry-After interval, or contact support to raise your limits.",
"type": "rate_limit_error",
"param": null,
"code": null
}
}{
"error": {
"message": "Rate limit exceeded. Retry after the Retry-After interval, or contact support to raise your limits.",
"type": "rate_limit_error",
"param": null,
"code": null
}
}{
"error": {
"message": "Rate limit exceeded. Retry after the Retry-After interval, or contact support to raise your limits.",
"type": "rate_limit_error",
"param": null,
"code": null
}
}https://models.relace.ai/v1 with your Relace API key.
Models
| Model | model ID | Context | Input | Output | Cached Input |
|---|---|---|---|---|---|
| DeepSeek V4 Flash 0731 | deepseek-ai/DeepSeek-V4-Flash-0731 | 1M | $0.065 / M | $0.18 / M | $0.016 / M |
| Kimi K3 | moonshotai/kimi-k3 | 1M | $3.00 / M | $15.00 / M | $0.30 / M |
| GLM 5.3 Flash | z-ai/glm-5.3-flash | 1M | $0.07125 / M | $0.2375 / M | $0.01425 / M |
Prompt Caching
Prompt caching is automatic. Cache hits are billed at the Cached Input rate and reported inusage.prompt_tokens_details.cached_tokens. To keep a multi-turn session on its cache, set prompt_cache_key to a stable value per session. See Prompt Caching and Session Affinity.Authorizations
Relace API key Authorization header using the Bearer scheme.
Body
OpenAI-compatible chat completions request
OpenAI-compatible request. Supported sampling parameters vary slightly by model.
ID of the hosted model to use, e.g. deepseek-ai/DeepSeek-V4-Flash-0731 or moonshotai/kimi-k3.
The conversation so far, as OpenAI-format message objects with role and content.
If true, tokens are sent as server-sent events as they are generated. Token usage is always reported in the final chunk of the stream.
Maximum number of tokens to generate. Reasoning tokens count toward this limit, so set a generous budget.
Sampling temperature. Higher values make output more random.
Nucleus sampling: only tokens within the top top_p probability mass are considered.
Only the top_k most likely tokens are considered at each step.
Up to 4 sequences at which generation stops.
Penalizes tokens by how often they have appeared so far. Range -2 to 2.
Penalizes tokens that have appeared at all so far. Range -2 to 2.
Multiplicative penalty on repeated tokens. Values above 1 discourage repetition.
OpenAI-format function tool definitions the model may call.
Controls tool use: none, auto, required, or a specific tool.
Set to {"type": "json_object"} for JSON mode. Kimi K3 only.
Cache affinity key. Requests with the same key are served by the same server, improving cache hit rates for multi-turn sessions. Use a stable value per conversation or session. Compatible with OpenAI's parameter of the same name.
512Response
Chat completion generated
Unique identifier for the completion
Always chat.completion
Unix timestamp of when the completion was created
The model that served the request
The generated completions
Show child attributes
Show child attributes
Token usage information for the request
Show child attributes
Show child attributes