Skip to main content
POST
cURL
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.

Request

Every other standard field (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.
Send 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

Authorization
string
header
required

The workspace API key (pdk_…) from Integrations → Built-in in the pre.dev dashboard.

Headers

x-predev-project-id
string

Attribute this call to one of the workspace's projects. An id the workspace does not own is ignored.

Body

application/json
model
string
required

A model id exactly as listed by GET /v1/models.

Example:

"deepseek/deepseek-v4.1-flash"

messages
object[]
required
Minimum array length: 1
models
string[]

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.

stream
boolean
default:false

Return server-sent events. The final chunk before data: [DONE] carries usage.

Example:

false

stream_options
object

Optional. pre.dev turns include_usage on for every stream.

max_tokens
integer

Upper bound on output tokens. Reasoning tokens count toward it, so turn reasoning off or allow more when you keep it small.

Required range: x >= 1
Example:

100

max_completion_tokens
integer
Required range: x >= 1
temperature
number
top_p
number
seed
integer
stop
tools
object[]
tool_choice

auto, none, required, or { "type": "function", "function": { "name": "…" } }.

Available options:
auto,
none,
required
parallel_tool_calls
boolean
response_format
object

Ask for JSON. json_schema enforces a schema on models whose catalog row lists structured_outputs in supported_parameters.

reasoning
object

Reasoning controls for models that support them. Reasoning tokens count as output tokens.

reasoning_effort
string

Shorthand for reasoning.effort.

modalities
enum<string>[]

Output modalities, for models that can return images or audio.

Available options:
text,
image,
audio
plugins
object[]
session_id
string

Groups related requests, such as one conversation.

user
string

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].

id
string
required

Generation id (pdg-…). Pass it to GET /v1/generation.

object
string
required
Allowed value: "chat.completion"
model
string
required

The model that served the call.

choices
object[]
required
created
integer
usage
object

Token counts for the call. Charges are reported in credits by the x-predev-credits-charged header and GET /v1/generation.

system_fingerprint
null