Skip to main content
Important Notice: As of April 25th, 2025, the @helicone/generate SDK has been discontinued. We launched a new prompts feature with improved composability and versioning on July 20th, 2025.The SDK and the legacy prompts feature will continue to function until August 20th, 2025.

Installation

Usage

Simple usage with just a prompt ID

With variables

With Helicone properties

In a chat

Supported Providers and Required Environment Variables

Ensure all required environment variables are correctly defined in your .env file before making a request.
Always required: HELICONE_API_KEY
ProviderRequired Environment Variables
OpenAIOPENAI_API_KEY
Azure OpenAIAZURE_API_KEY, AZURE_ENDPOINT, AZURE_DEPLOYMENT
AnthropicANTHROPIC_API_KEY
AWS BedrockBEDROCK_API_KEY, BEDROCK_REGION
Google GeminiGOOGLE_GEMINI_API_KEY
Google Vertex AIGOOGLE_VERTEXAI_API_KEY, GOOGLE_VERTEXAI_REGION, GOOGLE_VERTEXAI_PROJECT, GOOGLE_VERTEXAI_LOCATION
OpenRouterOPENROUTER_API_KEY

API Reference

generate(input)

Generates a response using a Helicone prompt.

Parameters

  • input (string | object): Either a prompt ID string or a parameters object:
    • promptId (string): The ID of the prompt to use, created in the Prompt Editor
    • version (number | “production”, optional): The version of the prompt to use. Defaults to “production”
    • inputs (object, optional): Variable inputs to use in the prompt, if any
    • chat (string[], optional): Chat history for chat-based prompts
    • userId (string, optional): User ID for tracking in Helicone
    • sessionId (string, optional): Session ID for tracking in Helicone Sessions
    • cache (boolean, optional): Whether to use Helicone’s LLM Caching

Returns

  • Promise<object>: The raw response from the LLM provider