OpenAdapterOpenAdapter
Advanced

Structured Output

Force the model to respond in valid JSON. Use `response_format` to get predictable, parseable output for your applications.

Base URL & authentication

Base URL: https://api.openadapter.in

All requests need an Authorization: Bearer sk-cv-... header. Generate or copy your API key from the Dashboard → API Keys page.

Force the model to respond in valid JSON. Use response_format to get predictable, parseable output for your applications.

curl https://api.openadapter.in/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-4.7",
    "messages": [
      {"role": "system", "content": "Extract contact info as JSON."},
      {"role": "user", "content": "John Smith, email john@example.com, phone 555-0123"}
    ],
    "response_format": {"type": "json_object"}
  }'

Tip: Always include "JSON" in your system prompt when using JSON mode. Most models need this hint to produce valid JSON reliably.

response = client.chat.completions.create(
    model="glm-4.7",
    messages=[
        {"role": "system", "content": "Extract contact info as JSON."},
        {"role": "user", "content": "John Smith, email john@example.com, phone 555-0123"}
    ],
    response_format={"type": "json_object"}
)

import json
data = json.loads(response.choices[0].message.content)
print(data)
# {"name": "John Smith", "email": "john@example.com", "phone": "555-0123"}
const response = await client.chat.completions.create({
  model: 'glm-4.7',
  messages: [
    { role: 'system', content: 'Extract contact info as JSON.' },
    { role: 'user', content: 'John Smith, email john@example.com, phone 555-0123' },
  ],
  response_format: { type: 'json_object' },
});

const data = JSON.parse(response.choices[0].message.content);
console.log(data);
// {name: "John Smith", email: "john@example.com", phone: "555-0123"}