API Reference
Structured Responses
Getting the model to reply with clean, parseable data — usually JSON — instead of free-form prose.
/v1/chat/completions does not currently accept an OpenAI-style response_format parameter — see the full accepted body in Chat Completions. If you send response_format today it's silently ignored rather than enforced. Until that's added, the reliable way to get structured output is through the prompt itself, below.Prompting for JSON today
Instruct the model explicitly, in the system message, to return only JSON matching a shape you describe — then parse the response text yourself.
curl https://api.dravenai.lat/v1/chat/completions \
-H "Authorization: Bearer sk-drv-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "your-model-id",
"messages": [
{ "role": "system", "content": "Reply with ONLY valid JSON, no markdown fences, matching: {\"city\": string, \"country\": string}." },
{ "role": "user", "content": "Where is the Eiffel Tower?" }
],
"temperature": 0.2
}'
completion = client.chat.completions.create(
model="your-model-id",
messages=[
{"role": "system", "content": 'Reply with ONLY valid JSON, no markdown fences, matching: {"city": string, "country": string}.'},
{"role": "user", "content": "Where is the Eiffel Tower?"},
],
temperature=0.2,
)
import json
data = json.loads(completion.choices[0].message.content)
const completion = await client.chat.completions.create({
model: "your-model-id",
messages: [
{ role: "system", content: 'Reply with ONLY valid JSON, no markdown fences, matching: {"city": string, "country": string}.' },
{ role: "user", content: "Where is the Eiffel Tower?" },
],
temperature: 0.2,
});
const data = JSON.parse(completion.choices[0].message.content);
Making it robust
- Describe the exact shape in the system prompt, including field names and types, ideally with a one-line example.
- Say "JSON only, no markdown fences, no commentary" explicitly — models default to wrapping JSON in triple-backtick code fences otherwise.
- Parse defensively. Wrap
JSON.parse/json.loadsin a try/catch, and strip a leading/trailing```jsonfence if one slips through. - Lower
temperature(see Chat Completions) for more consistent formatting across calls.
A dedicated
response_format: { "type": "json_object" } parameter that enforces valid JSON server-side is a natural next step for this API — check back here as the model catalog grows.