What you will accomplish
- Call the chat completions endpoint
- Read the answer from the response
- Know how streaming works
Before you start
- A private API key in the SYNTIC_API_KEY environment variable (see Create an API key)
- A terminal with curl
Step 1: Send a request
Call
POST https://app.syntic.ai/v1/chat/completionswith your key as a Bearer token. Name the model, setstream, and pass the conversation asmessages.curl -sS https://app.syntic.ai/v1/chat/completions \ -H "Authorization: Bearer $SYNTIC_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "Amara Deep", "stream": false, "messages": [ { "role": "system", "content": "Answer in one sentence." }, { "role": "user", "content": "Why do onions make people cry?" } ] }'Step 2: Read the reply
The answer is in
choices[0].message.contentof the JSON response.Step 3: Decide on streaming
Always send
streamexplicitly. If you leave it out the API streams by default, and the reply arrives as a series ofdata:lines instead of one JSON object. Set"stream": truewhen you want to show the answer as it's written.Step 4: When something fails
Every error response carries an
x-syntic-request-idheader. Include it when you contact support.
Tips
The full reference (models, parameters and the streaming format) is in the developer docs.
Next step
Build with the Syntic API · Lesson 3 of 3
Using Syntic CLI Remote Control