Agent loops (TypeScript)
Keep conversation state in your application. When a model requests a function tool, validate its arguments, execute only an allowed handler, return the result, and impose a maximum number of steps. Tool support varies by model.
This guide uses the official OpenAI client with TheRouter; it is not a TheRouter-owned SDK. The therouter and @therouter/sdk packages previously named here are not currently published in the public package registries.