Cursor request timeout: measure before you raise the limit

Three different failures look identical from the editor: nothing comes back. They need three different fixes, and the default response (raise the timeout) only helps one of them.

You need a key before the code below runs. Create an account, generate a key, and copy the base URL (https://aicomp.ai/v1). Create one free →
Check current rates → Free to sign up · $1 minimum top-up · No prepayment

One command separates them

Ask the endpoint how long a comparable request actually takes, from the same machine:

Don't have an account yet? You need an API key from the gateway before the steps below will work — how the discount works and what you take on. Create one free → (no prepay, $1 minimum top-up)
# -w prints the breakdown: how long to connect, and how long to first byte
curl -s -o /dev/null --max-time 120 \
  -w "dns %{time_namelookup}s connect %{time_connect}s ttfb %{time_starttransfer}s total %{time_total}s\n" \
  https://aicomp.ai/v1/chat/completions \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"claude-sonnet-5","messages":[{"role":"user","content":"Say ok"}],"max_tokens":16}'

Read the shape of the numbers:

Why agent sessions time out and chat does not

Agent mode sends a bigger request every turn. The conversation, every file it read, and the output of every command it ran all go back with the next call. By turn fifteen, the request is many times the size of the one you typed.

So the failure is rarely "the server is slow". It is that the request grew past what finishes inside the client's patience And it will keep growing unless you change the shape of the session, not the timeout value.

Cut the session, not the wait. Ending a task in eight turns instead of twenty removes more latency than any timeout setting, because it removes tokens from every subsequent request rather than extending the deadline on a request that should not be that large.

Cap the output when you can. A request that is allowed to generate a very long response takes proportionally longer to finish. If you are waiting on a summary rather than a file rewrite, a lower max_tokens returns sooner and costs less.

The context limit hiding behind a timeout

This is the misdiagnosis worth calling out. A request over the model's context window is refused rather than processed. Depending on the client, that refusal can surface as a failure that looks like the request never completed.

Check it before you raise anything:

# What does this model actually accept?
curl -s https://aicomp.ai/v1/models -H "Authorization: Bearer $OPENAI_API_KEY" \
  | jq -r '.data[] | select(.id=="claude-sonnet-5") | "context \(.context_length) max_out \(.max_output_tokens)"'

If your session is near that number, you are not looking at a timeout. You are looking at a request that will never succeed at that size, and the fix is a shorter session or a larger-window model, not a longer wait.

When raising the timeout is correct

Sometimes the server genuinely is slow: long reasoning, a large file rewrite, a model under load. In that case raising the client timeout is the right fix, with one caveat (set it to a value you are willing to wait), not to a large number that turns a failure into a five-minute freeze. A request that has not produced a first byte in ninety seconds is rarely going to finish usefully.

Get API access

FAQ

FAQ

Is a timeout the same as a rate limit?

No. A rate limit is a 429, the server answered and declined. A timeout means no answer finished. They need opposite responses: a 429 means send less, while a read timeout on a genuinely slow request means wait longer or send something smaller.

Why does it only happen in agent mode?

Because agent requests grow. Every turn re-sends the conversation plus accumulated tool output, so the request you are waiting on is far larger than the message you typed. Chat sessions do not compound, which is why the same key times out in one mode and not the other.

Should I just set a very long timeout?

Only after you have confirmed the request is valid. A long timeout on a request that exceeds the context window converts an instant refusal into a long wait for the same failure. Measure first: if the request is near the context limit, shorten it instead.

Does streaming help?

It helps perceived latency, not throughput. Streaming delivers the first token sooner, so a slow response feels responsive, but the total time and the total tokens are unchanged. It will not rescue a request that is too large.

Can I tell whether it is my network or the endpoint?

Yes, with the timing breakdown above. DNS and connect times are yours; time-to-first-byte is mostly the endpoint's. A large connect time with a fast first byte points at your network or proxy configuration.

Related

Get API access

GPT rate card