Structured Outputs
Overview
The Lune API supports OpenAI's Structured Outputs feature.
The base model Tycho defaults to claude-3-5-sonnet-20240620
.
However, when calling with a response format, Tycho will use gpt-4o
to generate a structured output response that adheres to the specified json schema.
Example Request
curl https://api.trylune.ai/chat/completions \
-H "Authorization: Bearer $LUNE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "tycho",
"messages": [
{
"role": "system",
"content": "Solve the math problem"
},
{
"role": "user",
"content": "how can I solve 8x + 7 = -23"
}
],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "math_reasoning",
"schema": {
"type": "object",
"properties": {
"steps": {
"type": "array",
"items": {
"type": "object",
"properties": {
"explanation": { "type": "string" },
"output": { "type": "string" }
},
"required": ["explanation", "output"],
"additionalProperties": false
}
},
"final_answer": { "type": "string" }
},
"required": ["steps", "final_answer"],
"additionalProperties": false
},
"strict": true
}
},
"stream": true
}'