Client / Schema
Turn language into typed data
Send source text and a strict JSON Schema. Receive an object your application can validate before use.POST
/api/v1/schemaExtract against a schema
TypeScripttypescript
const response = await fetch(
"https://api.neosyntropy.com/api/v1/chat/completions",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.NEOSYNTROPY_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "default",
messages: [{
role: "user",
content: "Maya Chen needs 3 Pro seats. Contact: maya@example.com",
}],
response_format: {
type: "json_schema",
json_schema: {
name: "sales_lead",
strict: true,
schema: {
type: "object",
properties: {
name: { type: "string" },
email: { type: "string" },
seats: { type: "integer" },
},
required: ["name", "email", "seats"],
additionalProperties: false,
},
},
},
}),
},
);
const completion = await response.json();
const lead = JSON.parse(completion.choices[0].message.content);Validate at the boundary
The response format constrains generation, but your application should still parse and validate the returned object with the same schema before storing or acting on it.