BEG
Nov 25

Tool API Context

Pass arbitrary context from generateText/streamText to tool execution via experimental_context. Access context in tool execute functions for dynamic behavior.

View Full Pattern on Desktop
Tool API Context preview

Problems Solved

  • Pass arbitrary context to tool execution
  • Dynamic tool behavior based on context
  • Access context in tool execute functions
  • Customize tool behavior without modifying tool definition

Use Cases

  • Passing user preferences to tools
  • Dynamic API key management
  • Context-aware tool behavior
  • User-specific tool customization

AI SDK APIs

streamTextconvertToModelMessagestool(useChatexperimental_context

Tags

aitoolsexperimental-contextcontextdynamic-behaviorai-sdktool-api

Requirements

Node.js
18+
Memory
512MB
Other
  • OpenAI API key

Environment Variables

External Services

openai

Ready to use?

View the full interactive pattern with live preview and copy the source code.

View Pattern on Desktop
End of Pattern