Quickstart
This walk-through takes you from an empty terminal to a working reply from an Amara model, then shows how to stream the answer and add instructions.
You need: a Syntic account with an organization in the Syntic Console, and either curl, Python 3.8+ or Node.js 18+. The Python and Node.js examples use the open-source openai package, which works with any OpenAI-compatible service once you change the base URL.
Create a key
Sign in to the Syntic Console, open Settings → API Keys and create a private key. Copy it right away; the Console shows the full value only once. More detail is in Get an API key.
Keep the key in an environment variable
Store the key outside your code so it never ends up in version control:
export SYNTIC_API_KEY="sk_live_..."Send a request
curl https://app.syntic.ai/v1/chat/completions \
-H "Authorization: Bearer $SYNTIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "Amara S1.2",
"stream": false,
"messages": [
{ "role": "user", "content": "Suggest three names for a bakery that only sells bagels." }
]
}'Read the reply
A successful call returns JSON like this (shortened):
{
"object": "chat.completion",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "1. Hole Lotta Love\n2. The Everything Shop\n3. Ring Theory" },
"finish_reason": "stop"
}
],
"usage": { "prompt_tokens": 131, "completion_tokens": 22, "total_tokens": 153 }
}The answer is in choices[0].message.content. The usage object tells you how many tokens the request used, which is what you are billed for. The prompt count includes a short instruction Syntic adds to every request, so it is a little higher than your message alone.
Add instructions
Put standing instructions in a system message at the start of the list. Here the model is asked to answer in a fixed format:
curl https://app.syntic.ai/v1/chat/completions \
-H "Authorization: Bearer $SYNTIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "Amara S1.2",
"stream": false,
"max_tokens": 300,
"messages": [
{ "role": "system", "content": "You name small businesses. Reply with exactly three names, one per line, no commentary." },
{ "role": "user", "content": "A repair shop for vintage typewriters in Lisbon." }
]
}'Stream the answer
Set stream to true (or leave it out of a raw HTTP request) and the reply arrives piece by piece as server-sent events. In Python:
stream = client.chat.completions.create(
model="Amara S1.2",
stream=True,
messages=[{"role": "user", "content": "Write a four-line poem about a lighthouse."}],
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)With an SDK, always pass stream explicitly. The SDK decides how to read the response from the value you give it, while the Syntic API streams whenever the field is missing. Leaving it out makes the SDK expect one JSON object and fail when a stream arrives.
Streaming explains the event format.
The Syntic API streams by default. The examples above set "stream": false so the whole reply arrives as one JSON object. Leave it out, or set it to true, to receive a stream instead; see Streaming.
If something goes wrong
| You see | Likely cause |
|---|---|
401 invalid_api_key | The key was mistyped or copied only partly. |
403 public_key_rejected | You used a pk_live_ public key. The API needs a private sk_live_ key. |
402 quota_exhausted | Your plan allowance is used up and usage credits are off or empty. |
| 429 | More than 600 requests in a minute with the same key. Wait for the Retry-After delay. |
| Reply looks like a different model than expected | The model name was misspelled, or the model is not in your plan; the default model answered. Check for an x-syntic-model-downgraded header. |
The full list is on the Errors page.
Next steps
- Quickstarts by language: the same first steps in curl, Python, JavaScript, Go, Java, C#, PHP and Ruby.
- Chat basics: roles, multi-turn conversations and every request field.
- Tool calling: let the model call your own functions.
- Models overview: pick the model that fits your task and budget.
- Usage & cost: see what your requests are spending in the Console.