Cookbook
Short recipes that solve one problem each. Every recipe is complete: copy it, set SYNTIC_API_KEY, and run it against https://app.syntic.ai/v1. For explanations of the concepts behind them, follow the links at the end of each recipe.
Streaming
| Recipe | What it shows |
|---|---|
| Stream with curl | Watch events arrive and pull out just the text with jq. |
| Stream in Python | Print text as it arrives, with and without a client library. |
| Stream in Node.js | Read the event stream with fetch, and with the OpenAI client library. |
| Cancel a stream | Stop a reply partway, for a Stop button or a timeout. |
Reliability and billing
| Recipe | What it shows |
|---|---|
| Retries with back-off | Retry 429 and 5xx responses safely, honouring Retry-After. |
| Handle 402 quota_exhausted | Tell the user why the request stopped and when it will work again. |
| Count cost from usage | Turn each response’s usage into dollars and log it. |
Tools
| Recipe | What it shows |
|---|---|
| Tool loop in Python | The smallest complete tool loop, about 50 lines. |
| Tool loop in TypeScript | The same loop with types. |
Integration
| Recipe | What it shows |
|---|---|
| Call the API from a browser | CORS, origin-restricted keys, and when to use a backend instead. |
| Move from the OpenAI SDK | Change the base URL, key and model names; know what behaves differently. |
Was this page helpful?