Skip to main content
Generate text completions using Anthropic’s Claude models. This function supports multi-turn conversations, system prompts, tool use, and vision capabilities for sophisticated reasoning and analysis tasks.

Samples

Basic text generation

Generate a simple response:

Multi-turn conversation

Continue a conversation with message history:

Use a system prompt

Guide Claude’s behavior:

Control creativity with temperature

Adjust the randomness of responses:

Use tools (function calling)

Enable Claude to call functions:

Control stop sequences

Stop generation at specific sequences:

Use with API key name

Reference a stored API key:

Arguments

Returns

JSONB: The complete API response including:
  • id: Unique message identifier
  • type: Response type (always "message")
  • role: Role of the responder (always "assistant")
  • content: Array of content blocks (text, tool use, etc.)
  • model: Model used for generation
  • stop_reason: Why generation stopped (e.g., "end_turn", "max_tokens")
  • usage: Token usage statistics