Skip to main content
Agents bundle a model, instructions, and optional tools. They expose the two AI SDK execution modes: generate for single responses and stream for token streams.

1. Instantiate an agent

  • name identifies the agent for logging and telemetry.
  • instructions provide the default system prompt (override per call with system).
  • model expects a LanguageModel from the AI SDK. Pick the provider you need.

2. Generate a single response

The return value mirrors ai.generateText:
  • text holds the final answer.
  • response exposes raw metadata (messages, usage, tool calls, …).
  • loopTool tells you whether the tool loop was triggered.

Conversation mode

When you pass messages, AI Kit automatically injects the agent instructions as a system message.

3. Enable telemetry

The telemetry flag enables Langfuse export when instrumentation is configured. Call agent.withTelemetry(false) to disable it temporarily.

4. Keep exploring