Class: ActiveAgent::Providers::OpenRouter::Requests::ResponseFormat

Inherits:
Common::BaseModel
  • Object
show all
Defined in:
lib/active_agent/providers/open_router/requests/response_format.rb

Overview

Response format configuration for structured output

Enables JSON-formatted responses using OpenAI’s structured output format. When using structured output, OpenRouter automatically sets provider.require_parameters=true to route to compatible models.

Examples:

JSON object format

format = ResponseFormat.new(type: 'json_object')

JSON schema format

format = ResponseFormat.new(
  type: 'json_schema',
  json_schema: {
    name: 'user_profile',
    description: 'A user profile',
    schema: { type: 'object', properties: { name: { type: 'string' } } },
    strict: true
  }
)

See Also:

Instance Attribute Summary collapse

Method Summary

Methods inherited from Common::BaseModel

#<=>, #==, attribute, #deep_compact, #deep_dup, delegate_attributes, drop_attributes, inherited, #initialize, #inspect, keys, #merge!, required_attributes, #serialize, #to_h, #to_hash

Constructor Details

This class inherits a constructor from ActiveAgent::Providers::Common::BaseModel

Instance Attribute Details

#json_schemaHash?

Returns JSON schema configuration (required when type is ‘json_schema’).

Returns:

  • (Hash, nil)

    JSON schema configuration (required when type is ‘json_schema’)



40
# File 'lib/active_agent/providers/open_router/requests/response_format.rb', line 40

attribute :json_schema

#typeString

Returns response format type (‘json_object’ or ‘json_schema’).

Returns:

  • (String)

    response format type (‘json_object’ or ‘json_schema’)



32
# File 'lib/active_agent/providers/open_router/requests/response_format.rb', line 32

attribute :type, :string