CookbookMove from the OpenAI SDK

Move from the OpenAI SDK

Code written for the OpenAI client libraries talks to Syntic after three changes: the base URL, the API key and the model names. This recipe shows the change in each common setup, then lists the behaviours to check before you switch production traffic.

The three changes

SettingChange to
Base URLhttps://app.syntic.ai/v1
API keyA Syntic private key (sk_live_...)
ModelA Syntic name such as Amara S1.2, Amara Quick or Syntic Code
import os
from openai import OpenAI
 
# Before: client = OpenAI()
client = OpenAI(
    base_url="https://app.syntic.ai/v1",
    api_key=os.environ["SYNTIC_API_KEY"],
)
 
r = client.chat.completions.create(
    model="Amara S1.2",            # was a vendor model name
    messages=[{"role": "user", "content": "Hello"}],
    stream=False,
)
print(r.choices[0].message.content)

Map your models

If you usedStart with
A large general-purpose modelAmara S1.2
A small, fast, cheap modelAmara Quick
A reasoning-focused modelAmara Deep
A coding-focused modelSyntic Code

Then run your own test set on the candidates; see Test your prompts and Choosing a model.

⚠️

Today an unknown model name does not return an error: the request is answered by the default model, Amara S1.2. Leaving an old vendor name in your code therefore “works” while silently using a different model than you meant. Search your code and configuration for every model string. Not live yet — on develop: an unknown name returns 404 model_not_found.

Behaviours to check

AreaOn SynticWhat to do
stream defaulttrue when omittedPass stream=False explicitly wherever you expect a single JSON object. The libraries do not send stream unless you set it.
Samplingtemperature, top_p, n, penalties are accepted and ignoredRemove reliance on them; exactly one choice is returned.
response_format, seed, stop, logprobs, userIgnored todayValidate JSON yourself; see Extract data to JSON.
Message contentText stringsImage and file content parts are in preview.
Tool callingtools and tool_choice work as you expectNo change.
ErrorsFlat body, {"error": "code", ...}Branch on the status and error code; see Error codes. The libraries still raise their usual exception types by status.
Quota402 quota_exhausted when the plan window and credits are usedHandle it; see Handle 402 quota_exhausted.
Rate limit600 requests a minute per keyThe libraries’ built-in retries handle short bursts.
EndpointsPOST /v1/chat/completionsOther paths (embeddings, files, models list, assistants) are not available yet; several are in preview.
IdentityA short Syntic identity line precedes your system messageYour instructions apply unchanged; “which model are you?” is answered as Syntic AI.

A safe cut-over

  1. Change base URL, key and model names in a branch.
  2. Search for stream usage and add stream=False where code expects a single object.
  3. Run your test suite and a sample of real prompts against Syntic; compare quality and latency.
  4. Log x-syntic-request-id, x-syntic-billing-source and x-syntic-model-downgraded for the first weeks.
  5. Move traffic over gradually, behind a configuration flag you can flip back.
Was this page helpful?