curl --fail-with-body https://api.pre.dev/v1/messages \
-H "x-api-key: $PREDEV_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "anthropic/claude-sonnet-5", "max_tokens": 100, "messages": [{"role": "user", "content": "Give me a haiku about deploys."}]}'import os
from anthropic import Anthropic
client = Anthropic(base_url="https://api.pre.dev", api_key=os.environ["PREDEV_API_KEY"])
message = client.messages.create(
model="anthropic/claude-sonnet-5",
max_tokens=100,
messages=[{"role": "user", "content": "Give me a haiku about deploys."}],
)
print(message.content[0].text)import Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic({ baseURL: 'https://api.pre.dev', apiKey: process.env.PREDEV_API_KEY });
const message = await client.messages.create({
model: 'anthropic/claude-sonnet-5',
max_tokens: 100,
messages: [{ role: 'user', content: 'Give me a haiku about deploys.' }],
});
console.log(message.content);<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.pre.dev/v1/messages",
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' => 'anthropic/claude-sonnet-5',
'messages' => [
[
'role' => 'user',
'content' => 'Give me a haiku about deploys.'
]
]
]),
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/messages"
payload := strings.NewReader("{\n \"model\": \"anthropic/claude-sonnet-5\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Give me a haiku about deploys.\"\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/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"anthropic/claude-sonnet-5\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Give me a haiku about deploys.\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pre.dev/v1/messages")
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\": \"anthropic/claude-sonnet-5\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Give me a haiku about deploys.\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "pdg-043293a6-d1a8-4695-81fe-603ad4661ebb",
"type": "message",
"role": "assistant",
"model": "anthropic/claude-sonnet-5",
"content": [
{
"type": "text",
"text": "Green checks line up\nThe pipeline hums, then goes quiet\nProduction wakes up"
}
],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 14,
"output_tokens": 19
}
}Messages
POST /v1/messages in the Anthropic Messages shape, for the Anthropic SDK.
curl --fail-with-body https://api.pre.dev/v1/messages \
-H "x-api-key: $PREDEV_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "anthropic/claude-sonnet-5", "max_tokens": 100, "messages": [{"role": "user", "content": "Give me a haiku about deploys."}]}'import os
from anthropic import Anthropic
client = Anthropic(base_url="https://api.pre.dev", api_key=os.environ["PREDEV_API_KEY"])
message = client.messages.create(
model="anthropic/claude-sonnet-5",
max_tokens=100,
messages=[{"role": "user", "content": "Give me a haiku about deploys."}],
)
print(message.content[0].text)import Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic({ baseURL: 'https://api.pre.dev', apiKey: process.env.PREDEV_API_KEY });
const message = await client.messages.create({
model: 'anthropic/claude-sonnet-5',
max_tokens: 100,
messages: [{ role: 'user', content: 'Give me a haiku about deploys.' }],
});
console.log(message.content);<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.pre.dev/v1/messages",
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' => 'anthropic/claude-sonnet-5',
'messages' => [
[
'role' => 'user',
'content' => 'Give me a haiku about deploys.'
]
]
]),
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/messages"
payload := strings.NewReader("{\n \"model\": \"anthropic/claude-sonnet-5\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Give me a haiku about deploys.\"\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/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"anthropic/claude-sonnet-5\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Give me a haiku about deploys.\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pre.dev/v1/messages")
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\": \"anthropic/claude-sonnet-5\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Give me a haiku about deploys.\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "pdg-043293a6-d1a8-4695-81fe-603ad4661ebb",
"type": "message",
"role": "assistant",
"model": "anthropic/claude-sonnet-5",
"content": [
{
"type": "text",
"text": "Green checks line up\nThe pipeline hums, then goes quiet\nProduction wakes up"
}
],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 14,
"output_tokens": 19
}
}POST https://api.pre.dev/v1/messages accepts the Anthropic Messages request body and returns the Anthropic response. Use it with the Anthropic SDK: set the client’s baseURL to https://api.pre.dev, without /v1, because the SDK appends /v1/messages itself. Pass the pre.dev key as the API key; the SDK’s x-api-key header is accepted.
Model ids are the catalog ids exactly as listed by GET /v1/models, so anthropic/claude-sonnet-5 rather than a native Anthropic model name. Any chat model in the catalog works through this shape, not only Anthropic’s.
curl --fail-with-body https://api.pre.dev/v1/messages \
-H "x-api-key: $PREDEV_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-5",
"max_tokens": 256,
"messages": [{ "role": "user", "content": "Give me a haiku about deploys." }]
}'
import Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic({
baseURL: 'https://api.pre.dev', // no /v1: the Anthropic SDK appends /v1/messages itself
apiKey: process.env.PREDEV_API_KEY!,
});
const message = await client.messages.create({
model: 'anthropic/claude-sonnet-5',
max_tokens: 256,
messages: [{ role: 'user', content: 'Give me a haiku about deploys.' }],
});
console.log(message.content);
import os
from anthropic import Anthropic
client = Anthropic(
base_url="https://api.pre.dev",
api_key=os.environ["PREDEV_API_KEY"],
)
message = client.messages.create(
model="anthropic/claude-sonnet-5",
max_tokens=256,
messages=[{"role": "user", "content": "Give me a haiku about deploys."}],
)
print(message.content)
Streaming
Setstream: true, or use client.messages.stream() in the SDKs, for Anthropic-style server-sent events. Credits settle when the stream ends; a disconnect still charges what the model generated. See streaming.
Tools, system prompts, and images
Use the Anthropicsystem, tools, and content-block formats, with Anthropic models or any other chat model in the catalog.
Headers and billing
The samex-predev-request-id, x-predev-credits-charged, and x-predev-credits-remaining headers are returned, and x-predev-project-id attributes usage. Calls are charged from the model’s metered usage, as on pricing.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 catalog id such as anthropic/claude-sonnet-5, not a native Anthropic model name. Any chat model in the catalog works.
"anthropic/claude-sonnet-5"
1Show child attributes
Show child attributes
The Anthropic SDKs require it.
x >= 1Anthropic tool definitions (name, description, input_schema).
Extended thinking, on models that support it.
Response
The message. With stream: true, Anthropic-style server-sent events (text/event-stream) instead.
Generation id (pdg-…).
"message""assistant"Show child attributes
Show child attributes
"end_turn"
"max_tokens"
"stop_sequence"
"tool_use"
Show child attributes
Show child attributes
Was this page helpful?

