Skip to main content
chat() sends a request and waits for the full response. Use it when you need the complete output before continuing — data extraction, classification, or when streaming isn’t practical.

Basic usage

The response

chat() returns a ChatResponse with everything you need:

Controlling generation

Parameters you don’t pass stay at provider defaults. The gateway handles provider-specific quirks automatically — temperature is stripped for reasoning models (o3, o3-mini, o4-mini), max_tokens is renamed to max_completion_tokens where needed.

Aborting a request

Pass an AbortSignal to cancel an in-flight request:

Linking requests to the dashboard

Pass promptId to associate the request with a saved prompt for log correlation:
The prompt’s content is not used — this just tags the log entry. Run a saved prompt’s actual template through /v1/prompts/:slug/run instead.

Tracking end users

Pass endUserId to tag requests with a user identifier. This shows up in the logs so you can filter by user:

Error handling

The SDK throws a GatelitError with three fields: