LemonAi.Providers.OpenAIResponses (lemon_ai v0.1.0)

View Source

OpenAI Responses API provider.

This provider implements the OpenAI Responses API which supports:

  • Built-in reasoning/thinking support
  • Prompt caching
  • Service tier selection (flex, auto, priority)
  • Streaming responses

Configuration

The provider uses the following environment variables:

  • OPENAI_API_KEY - API key for OpenAI
  • PI_CACHE_RETENTION - Set to "long" for 24h prompt cache retention

Usage

model = %Model{
  id: "o1-preview",
  api: :openai_responses,
  provider: :openai,
  base_url: "https://api.openai.com/v1",
  reasoning: true
}

context = Context.new(
  system_prompt: "You are a helpful assistant.",
  messages: [%UserMessage{content: "Hello!"}]
)

{:ok, stream} = OpenAIResponses.stream(model, context, %StreamOptions{})