Hi @YardaG, taking your three questions in order.
1) Sonar or Agent API for this task?
Agent API is great for this task. Your task needs two things: live retrieval (finance_search for stocks, web_search for bonds) and output that follows a JSON schema. The Agent API is built for that combination. Sonar is a good fit for single-pass, search-grounded answers in chat format, but your task does not need anything from it that the Agent API lacks. With low + minimal reasoning, your payloads ran well within your 30-second timeout in our test runs. The general rule: pick the API by what the request has to do, then pick the preset that solves the task at your needed level of speed, cost, depth.
2) Is the payload overkill?
The payload isn’t overkill. The structure is right: preset, tools, response_format with a strict schema, capped max_output_tokens. Three things worth testing:
-
Send only the tool each request needs. Stocks get finance_search, bonds get web_search. Fewer tools means fewer decisions in the loop.
-
Move the taxonomy into the schema. If sector and industry are enum values in response_format, the model cannot return an invalid pair, and the prose taxonomy in your system prompt can shrink.
-
Set reasoning to minimal explicitly if you want it pinned. The updated low preset already defaults there.
3) Batching and reusing the system prompt
Prompt reuse: caching already does this for you. On supported models, repeated identical prompt prefixes are billed at the model’s cache-read rate (per-model rates are on the models page). Keep the taxonomy identical at the start of instructions and put the per-instrument content at the end. Check usage.cache_read_input_tokens in the response to confirm cache hits.
Multiple instruments per request: usually slower, not faster. Each instrument still needs its own searches. A 10-instrument request runs all of those tool calls one after another inside a single response, and if the request fails, you lose all 10 results.
For throughput, run requests in parallel instead. About 10 concurrent workers, with backoff on 429s, brings your 5,000-instrument run from ~22 hours down to roughly an hour. Another option is "background": true: the API returns immediately, you poll GET /v1/responses/{id}, and client timeouts stop mattering.
From what we saw in your payloads, the client got the fundamentals right: strict schema, retries, sensible token caps. Happy to look at the revised setup or answer any further questions