tool( )

Pattern

Tool API Context

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

BeginnerNov 2025View the 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
24+
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 the pattern on desktop

Related patterns

You’ve reached the end of this pattern.