SDKs & toolsDirect HTTP

Direct HTTP

You do not need a client library to use the Syntic API. Every call is one HTTPS POST with a JSON body, so any language with an HTTP client works. This page gives complete, copy-ready examples in several languages, plus a checklist for writing your own thin wrapper.

The request in every language

All examples send the same request: a short conversation to Amara S1.2, with stream set to false so the reply is one JSON object. Each reads the key from the SYNTIC_API_KEY environment variable and prints the reply, or the error code on failure.

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": "system", "content": "Answer in one sentence." },
      { "role": "user", "content": "Why do onions make people cry?" }
    ]
  }'

Streaming without a library

For a streamed reply, leave out stream (or set it to true), read the body line by line and handle each data: line. Complete Python and JavaScript readers, including tool-call assembly, are on Stream format.

Writing your own wrapper

If you wrap the API in a small helper for your codebase, make it do these things:

ConcernWhat to do
Key handlingRead the key from the environment or a secrets store. Never hard-code it.
streamAlways send it explicitly, true or false.
TimeoutsAllow at least a couple of minutes for non-streamed replies; long answers take time.
ErrorsBranch on the HTTP status, then on the error string. Treat 429 separately: its error is a sentence.
RetriesRetry 429 after Retry-After; retry 5xx and stream_error with exponential back-off. Do not retry other 4xx.
LoggingRecord x-syntic-request-id (and trace_id on 500) for every failed call.
FallbacksCheck for x-syntic-model-downgraded if your code depends on a specific model.
UsageRead usage from each reply if you track cost per feature or customer.

The codes behind each status are listed on Error codes.

🚫

Do not put a private key in mobile apps, desktop apps you distribute, or browser code. Anyone can extract it. Call the API from a server you control and give your client apps their own authentication.

Was this page helpful?