Class: RubyLLM::Providers::Azure

Inherits:
OpenAI show all
Includes:
Chat, Embeddings, Media, Models
Defined in:
lib/ruby_llm/providers/azure.rb,
lib/ruby_llm/providers/azure/chat.rb,
lib/ruby_llm/providers/azure/media.rb,
lib/ruby_llm/providers/azure/models.rb,
lib/ruby_llm/providers/azure/embeddings.rb

Overview

Azure AI Foundry / OpenAI-compatible API integration.

Defined Under Namespace

Modules: Chat, Embeddings, Media, Models

Constant Summary

Constants included from OpenAI::Tools

OpenAI::Tools::EMPTY_PARAMETERS_SCHEMA

Instance Attribute Summary

Attributes inherited from RubyLLM::Provider

#config, #connection

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Models

#models_url

Methods included from Media

format_content, format_image

Methods included from Embeddings

embedding_url, render_embedding_payload

Methods included from Chat

#completion_url, #format_messages, #format_role

Methods inherited from OpenAI

capabilities, #maybe_normalize_temperature

Methods included from OpenAI::Transcription

encode_speaker_references, parse_transcription_response, render_transcription_payload, response_format_for, supports_chunking_strategy?, transcription_url

Methods included from OpenAI::Media

format_audio, format_content, format_image, format_pdf, format_text, format_text_file

Methods included from OpenAI::Images

images_url, parse_image_response, render_image_payload

Methods included from OpenAI::Tools

format_tool_calls, param_schema, parameters_schema_for, parse_tool_call_arguments, parse_tool_calls, schema_from_parameters, tool_for

Methods included from OpenAI::Streaming

build_chunk, parse_streaming_error, stream_url

Methods included from OpenAI::Moderation

moderation_url, parse_moderation_response, render_moderation_payload

Methods included from OpenAI::Models

models_url, parse_list_models_response

Methods included from OpenAI::Embeddings

embedding_url, parse_embedding_response, render_embedding_payload

Methods included from OpenAI::Chat

#completion_url, extract_content_and_thinking, extract_text_from_blocks, extract_think_tag_content, extract_thinking_from_blocks, extract_thinking_signature, extract_thinking_text, extract_thinking_text_from_block, format_messages, format_role, format_thinking, parse_completion_response, render_payload, resolve_effort

Methods inherited from RubyLLM::Provider

#assume_models_exist?, capabilities, #capabilities, #complete, #configuration_requirements, configured_providers, configured_remote_providers, #embed, for, #format_messages, #format_tool_calls, #initialize, #list_models, #local?, local?, local_providers, #moderate, #name, name, #paint, #parse_error, #parse_tool_calls, providers, register, remote?, #remote?, remote_providers, resolve, slug, #slug, #transcribe

Methods included from Streaming

build_on_data_handler, build_stream_error_response, error_chunk?, faraday_1?, handle_data, handle_error_chunk, handle_error_event, handle_failed_response, handle_json_error_chunk, handle_parsed_error, handle_sse, handle_stream, json_error_payload?, parse_error_from_json, parse_streaming_error, process_stream_chunk, stream_response

Constructor Details

This class inherits a constructor from RubyLLM::Provider

Class Method Details

.assume_models_exist?Boolean

Azure works with deployment names, instead of model names

Returns:

  • (Boolean)


38
39
40
# File 'lib/ruby_llm/providers/azure.rb', line 38

def assume_models_exist?
  true
end

.configuration_requirementsObject



29
30
31
# File 'lib/ruby_llm/providers/azure.rb', line 29

def configuration_requirements
  i[azure_api_base]
end

.configured?(config) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/ruby_llm/providers/azure.rb', line 33

def configured?(config)
  config.azure_api_base && (config.azure_api_key || config.azure_ai_auth_token)
end

Instance Method Details

#api_baseObject



12
13
14
# File 'lib/ruby_llm/providers/azure.rb', line 12

def api_base
  @config.azure_api_base
end

#configured?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/ruby_llm/providers/azure.rb', line 24

def configured?
  self.class.configured?(@config)
end

#ensure_configured!Object

Raises:



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/ruby_llm/providers/azure.rb', line 43

def ensure_configured!
  missing = []
  missing << :azure_api_base unless @config.azure_api_base
  if @config.azure_api_key.nil? && @config.azure_ai_auth_token.nil?
    missing << 'azure_api_key or azure_ai_auth_token'
  end
  return if missing.empty?

  raise ConfigurationError,
        "Missing configuration for Azure: #{missing.join(', ')}"
end

#headersObject



16
17
18
19
20
21
22
# File 'lib/ruby_llm/providers/azure.rb', line 16

def headers
  if @config.azure_api_key
    { 'api-key' => @config.azure_api_key }
  else
    { 'Authorization' => "Bearer #{@config.azure_ai_auth_token}" }
  end
end