curl --fail-with-body https://api.pre.dev/v1/chat/completions \
-H "Authorization: Bearer $PREDEV_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"deepseek/deepseek-v4.1-flash","max_tokens":100,"stream":false,"reasoning":{"enabled":false},"messages":[{"role":"user","content":"Say hello in five words."}]}'import os
from openai import OpenAI
client = OpenAI(base_url="https://api.pre.dev/v1", api_key=os.environ["PREDEV_API_KEY"])
completion = client.chat.completions.create(
model="deepseek/deepseek-v4.1-flash",
max_tokens=100,
extra_body={"reasoning": {"enabled": False}},
messages=[{"role": "user", "content": "Say hello in five words."}],
)
print(completion.choices[0].message.content)import OpenAI from 'openai';
const client = new OpenAI({ baseURL: 'https://api.pre.dev/v1', apiKey: process.env.PREDEV_API_KEY });
const completion = await client.chat.completions.create({
model: 'deepseek/deepseek-v4.1-flash',
max_tokens: 100,
reasoning: { enabled: false },
messages: [{ role: 'user', content: 'Say hello in five words.' }],
});
console.log(completion.choices[0].message.content);<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.pre.dev/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/deepseek-v4.1-flash',
'messages' => [
[
'role' => 'user',
'content' => 'Say hello in five words.'
]
]
]),
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://api.pre.dev/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"deepseek/deepseek-v4.1-flash\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Say hello in five words.\"\n }\n ]\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://api.pre.dev/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"deepseek/deepseek-v4.1-flash\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Say hello in five words.\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pre.dev/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/deepseek-v4.1-flash\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Say hello in five words.\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "pdg-043293a6-d1a8-4695-81fe-603ad4661ebb",
"object": "chat.completion",
"created": 1790500000,
"model": "deepseek/deepseek-v4.1-flash",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello there, nice to meet you."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 8,
"total_tokens": 20
},
"system_fingerprint": null
}Chat completions
POST /v1/chat/completions, /v1/completions, and /v1/responses in the OpenAI-compatible shape.
curl --fail-with-body https://api.pre.dev/v1/chat/completions \
-H "Authorization: Bearer $PREDEV_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"deepseek/deepseek-v4.1-flash","max_tokens":100,"stream":false,"reasoning":{"enabled":false},"messages":[{"role":"user","content":"Say hello in five words."}]}'import os
from openai import OpenAI
client = OpenAI(base_url="https://api.pre.dev/v1", api_key=os.environ["PREDEV_API_KEY"])
completion = client.chat.completions.create(
model="deepseek/deepseek-v4.1-flash",
max_tokens=100,
extra_body={"reasoning": {"enabled": False}},
messages=[{"role": "user", "content": "Say hello in five words."}],
)
print(completion.choices[0].message.content)import OpenAI from 'openai';
const client = new OpenAI({ baseURL: 'https://api.pre.dev/v1', apiKey: process.env.PREDEV_API_KEY });
const completion = await client.chat.completions.create({
model: 'deepseek/deepseek-v4.1-flash',
max_tokens: 100,
reasoning: { enabled: false },
messages: [{ role: 'user', content: 'Say hello in five words.' }],
});
console.log(completion.choices[0].message.content);<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.pre.dev/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/deepseek-v4.1-flash',
'messages' => [
[
'role' => 'user',
'content' => 'Say hello in five words.'
]
]
]),
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://api.pre.dev/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"deepseek/deepseek-v4.1-flash\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Say hello in five words.\"\n }\n ]\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://api.pre.dev/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"deepseek/deepseek-v4.1-flash\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Say hello in five words.\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pre.dev/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/deepseek-v4.1-flash\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Say hello in five words.\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "pdg-043293a6-d1a8-4695-81fe-603ad4661ebb",
"object": "chat.completion",
"created": 1790500000,
"model": "deepseek/deepseek-v4.1-flash",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello there, nice to meet you."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 8,
"total_tokens": 20
},
"system_fingerprint": null
}POST https://api.pre.dev/v1/chat/completions takes the OpenAI-compatible chat completion request body and returns the chat completion response. POST /v1/completions (text completions) and POST /v1/responses (Responses API shape) work the same way with their own bodies.
curl --fail-with-body -i https://api.pre.dev/v1/chat/completions \
-H "Authorization: Bearer $PREDEV_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek/deepseek-v4.1-flash",
"messages": [
{ "role": "system", "content": "Answer in one sentence." },
{ "role": "user", "content": "Why is the sky blue?" }
]
}'
import OpenAI from 'openai';
const client = new OpenAI({ baseURL: 'https://api.pre.dev/v1', apiKey: process.env.PREDEV_API_KEY! });
const { data: completion, response } = await client.chat.completions
.create({
model: 'deepseek/deepseek-v4.1-flash',
messages: [
{ role: 'system', content: 'Answer in one sentence.' },
{ role: 'user', content: 'Why is the sky blue?' },
],
})
.withResponse();
console.log(completion.choices[0].message.content);
console.log('credits:', response.headers.get('x-predev-credits-charged'));
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.pre.dev/v1", api_key=os.environ["PREDEV_API_KEY"])
raw = client.chat.completions.with_raw_response.create(
model="deepseek/deepseek-v4.1-flash",
messages=[
{"role": "system", "content": "Answer in one sentence."},
{"role": "user", "content": "Why is the sky blue?"},
],
)
completion = raw.parse()
print(completion.choices[0].message.content)
print("credits:", raw.headers.get("x-predev-credits-charged"))
Request
| Field | Notes |
|---|---|
model | The model id exactly as listed by GET /v1/models; append :online for web search |
messages | OpenAI chat messages, including image and file content parts |
models, route, transforms | Fallbacks and advanced options |
reasoning, reasoning_effort | Reasoning controls |
plugins, web_search_options | Plugins and web search |
response_format, structured_outputs, tools, tool_choice, parallel_tool_calls | Tools and structured output |
prediction, verbosity, session_id | Predicted outputs, verbosity, session grouping |
stream | Streaming; the final chunk carries usage |
user | End-user identifier; pre.dev prefixes it with an identifier for your workspace |
temperature, max_tokens, stop, and so on) works as in the OpenAI API.
Response
The body is the standard chat completion response.id is the pre.dev generation id (pdg-…), model is the model that answered, and usage has the token counts.
{
"id": "pdg-7c1e4b52-9a3d-4f8e-b0c6-2d5a8e913f47",
"object": "chat.completion",
"model": "deepseek/deepseek-v4.1-flash",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "Sunlight scatters off air molecules, and blue light scatters most." },
"finish_reason": "stop"
}
],
"usage": { "prompt_tokens": 21, "completion_tokens": 14, "total_tokens": 35 }
}
| Header | Meaning |
|---|---|
x-predev-request-id | pdr_…, the gateway’s id for this call |
x-predev-credits-charged | Credits charged. Not sent on streamed responses; read GET /v1/generation afterwards |
x-predev-credits-remaining | Balance after the call; omitted when the workspace has no credit limit |
x-predev-project-id: <projectId> to attribute the call to a project. See usage.
Errors
Errors use the OpenAI error shape. Account and billing errors (401, 402, 429, 503) add a predev object; errors from the model, such as an unknown model id, keep their HTTP status. See errors.Authorizations
The workspace API key (pdk_…) from Integrations → Built-in in the pre.dev dashboard.
Headers
Attribute this call to one of the workspace's projects. An id the workspace does not own is ignored.
Body
A model id exactly as listed by GET /v1/models.
"deepseek/deepseek-v4.1-flash"
1Show child attributes
Show child attributes
Fallback model ids, tried in order when the first choice cannot serve the request. The response model names the model that answered, and the charge follows that model.
Return server-sent events. The final chunk before data: [DONE] carries usage.
false
Optional. pre.dev turns include_usage on for every stream.
Show child attributes
Show child attributes
Upper bound on output tokens. Reasoning tokens count toward it, so turn reasoning off or allow more when you keep it small.
x >= 1100
x >= 1Show child attributes
Show child attributes
auto, none, required, or { "type": "function", "function": { "name": "…" } }.
auto, none, required Ask for JSON. json_schema enforces a schema on models whose catalog row lists structured_outputs in supported_parameters.
Show child attributes
Show child attributes
Reasoning controls for models that support them. Reasoning tokens count as output tokens.
Show child attributes
Show child attributes
Shorthand for reasoning.effort.
Output modalities, for models that can return images or audio.
text, image, audio Show child attributes
Show child attributes
Groups related requests, such as one conversation.
Your id for the end user. pre.dev prefixes it with a hash of your workspace.
Response
The completion. With stream: true, server-sent chunks in the OpenAI format ending with data: [DONE].
Generation id (pdg-…). Pass it to GET /v1/generation.
"chat.completion"The model that served the call.
Show child attributes
Show child attributes
Token counts for the call. Charges are reported in credits by the x-predev-credits-charged header and GET /v1/generation.
Show child attributes
Show child attributes
Was this page helpful?

