Quickstart: curl

curl is the quickest way to try the API and to reproduce a problem when you report it. You need curl 7.76 or later and, for the nicer output below, jq.

Check your key is set

test -n "$SYNTIC_API_KEY" && echo "key is set" || echo "set SYNTIC_API_KEY first"

Send a request

curl -sS 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": "In one sentence, what is a sourdough starter?"}]
  }'

The reply is one JSON object. The text is in choices[0].message.content; token counts are in usage.

curl -sS 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": "In one sentence, what is a sourdough starter?"}]}' \
  | jq -r '.choices[0].message.content'

Add instructions

Put rules that apply to the whole conversation in a system message first:

curl -sS 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": 200,
    "messages": [
      {"role": "system", "content": "You are a baking coach. Answer in at most three short bullet points."},
      {"role": "user", "content": "My starter smells like nail polish. What now?"}
    ]
  }' | jq -r '.choices[0].message.content'

Keep a request in a file

Long requests are easier to edit as files. -d @file sends the file as the body:

cat > request.json <<'JSON'
{
  "model": "Amara Quick",
  "stream": false,
  "messages": [
    {"role": "system", "content": "Reply in Spanish."},
    {"role": "user", "content": "Where is the nearest bakery?"}
  ]
}
JSON
 
curl -sS https://app.syntic.ai/v1/chat/completions \
  -H "Authorization: Bearer $SYNTIC_API_KEY" -H "Content-Type: application/json" \
  -d @request.json | jq -r '.choices[0].message.content'

To insert a text file safely (quotes and newlines escaped), build the JSON with jq:

jq -n --rawfile doc notes.txt '{model: "Amara S1.2", stream: false,
  messages: [{role: "user", content: ("Summarise in 3 bullets:\n\n" + $doc)}]}' \
| curl -sS https://app.syntic.ai/v1/chat/completions \
    -H "Authorization: Bearer $SYNTIC_API_KEY" -H "Content-Type: application/json" -d @- \
| jq -r '.choices[0].message.content'

Stream the reply

Leave out stream and use -N so curl prints events as they arrive:

curl -sN https://app.syntic.ai/v1/chat/completions \
  -H "Authorization: Bearer $SYNTIC_API_KEY" -H "Content-Type: application/json" \
  -d '{"model": "Amara Quick", "messages": [{"role": "user", "content": "Write a limerick about rye bread."}]}' \
| sed -u -n 's/^data: //p' | grep --line-buffered -v '^\[DONE\]$' \
| jq --unbuffered -j '.choices[0].delta.content // empty'; echo

More options are in Stream with curl.

Offer a function

curl -sS 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,
    "tools": [{"type": "function", "function": {
      "name": "oven_temperature",
      "description": "Convert an oven temperature between Celsius, Fahrenheit and gas mark.",
      "parameters": {"type": "object", "properties": {
        "value": {"type": "number"}, "from": {"type": "string", "enum": ["C", "F", "gas"]}},
        "required": ["value", "from"]}}}],
    "messages": [{"role": "user", "content": "What is gas mark 6 in Celsius?"}]
  }' | jq '.choices[0].message.tool_calls'

The reply asks you to run oven_temperature; send the result back in a tool message as shown in Tool calling.

See headers and errors

curl -sS -D - -o body.json -w 'status %{http_code}\n' https://app.syntic.ai/v1/chat/completions \
  -H "Authorization: Bearer $SYNTIC_API_KEY" -H "Content-Type: application/json" \
  -d '{"model": "Amara Quick", "stream": false, "messages": []}' | grep -iE '^x-syntic|^status'
cat body.json      # {"error":"messages_required"}
You seeMeaning
status 401 and invalid_api_keyThe key is wrong or the variable is empty.
status 400 and messages_requiredmessages is missing or empty.
status 402 and quota_exhaustedPlan allowance and credits are used up; see Handle 402.
status 429More than 600 requests this minute; wait Retry-After seconds.

Include the x-syntic-request-id header value in any support ticket about a request.

Next steps

Was this page helpful?