Generation Provider
Generation Providers are the backbone of the Active Agent framework, allowing seamless integration with various AI services. They provide a consistent interface for prompting and generating responses, making it easy to switch between different providers without changing the core logic of your application.
Available Providers
You can use the following generation providers with Active Agent:
class OpenAIAgent < ApplicationAgent
layout "agent"
generate_with :openai, model: "gpt-4o-mini", instructions: "You're a basic OpenAI agent."
end
class ApplicationAgent < ActiveAgent::Base
generate_with :anthropic
end
class ApplicationAgent < ActiveAgent::Base
generate_with :google
end
class OpenRouterAgent < ApplicationAgent
layout "agent"
generate_with :open_router, model: "qwen/qwen3-30b-a3b:free", instructions: "You're a basic Open Router agent."
end
class OllamaAgent < ApplicationAgent
layout "agent"
generate_with :ollama, model: "gemma3:latest", instructions: "You're a basic Ollama agent."
end
Response
Generation providers handle the request-response cycle for generating responses based on the provided prompts. They process the prompt context, including messages, actions, and parameters, and return the generated response.
Response Object
The ActiveAgent::GenerationProvider::Response
class encapsulates the result of a generation request, providing access to both the processed response and debugging information.
Attributes
message
- The generated response message from the AI providerprompt
- The complete prompt object used for generation, including updated context, messages, and parametersraw_response
- The unprocessed response data from the AI provider, useful for debugging and accessing provider-specific metadata
Example Usage
class ApplicationAgent < ActiveAgent::Base
layout "agent"
generate_with :openai, model: "gpt-4o-mini", instructions: "You're just a basic agent", stream: true
end
# Access the response message
puts response.message
# Inspect the prompt that was sent
puts response.prompt.inspect
# Access the messages in the prompt
puts response.prompt.messages.inspect
# Debug with raw response data
puts response.raw_response.inspect
The response object ensures you have full visibility into both the input prompt context and the raw provider response, making it easy to debug generation issues or access provider-specific response metadata.