Class: LLM::Alibaba

Inherits:
OpenAI show all
Defined in:
lib/llm/providers/alibaba.rb,
lib/llm/providers/alibaba/error_handler.rb,
lib/llm/providers/alibaba/request_adapter.rb

Overview

The Alibaba class implements a provider for Alibaba Cloud Model Studio through its OpenAI-compatible API, including the Qwen3 family of models.

The default host is the pay-as-you-go DashScope international endpoint (dashscope-intl.aliyuncs.com). Configure a different host either globally through the ALIBABA_API_HOST environment variable, or per instance through LLM.alibaba(host: "token-plan.ap-southeast-1.maas.aliyuncs.com") (for example Alibaba's Token Plan).

Examples:

#!/usr/bin/env ruby
require "llm"

llm = LLM.alibaba(key: ENV["DASHSCOPE_API_KEY"])
ctx = LLM::Context.new(llm)
ctx.talk "Hello"

Defined Under Namespace

Modules: RequestAdapter Classes: ErrorHandler

Constant Summary collapse

HOST =
"dashscope-intl.aliyuncs.com"
BASE_PATH =
"/compatible-mode/v1"

Instance Method Summary collapse

Methods inherited from OpenAI

#adapt_function, #assistant_role, #complete, #embed, #files, #models, #server_tools, #web_search

Methods included from OpenAI::RequestAdapter

#adapt

Methods inherited from Provider

#adapt_function, #assistant_role, #build_messages, #chat, #complete, #developer_role, #embed, #files, #inspect, #interrupt!, #key?, #models, #ocr, #registry, #request_owner, #respond, #schema, #server_tool, #server_tools, #system_role, #tool_role, #tracer, #tracer=, #user_role, #web_search, #with, #with_tracer

Constructor Details

#initialize(host: ENV.fetch("DASHSCOPE_API_HOST", HOST), base_path: BASE_PATH) ⇒ LLM::Alibaba

Parameters:

  • key (String, nil)

    The secret key for authentication

  • host (String) (defaults to: ENV.fetch("DASHSCOPE_API_HOST", HOST))

    The host address of the LLM provider

  • base_path (String) (defaults to: BASE_PATH)

    Optional base path prefix for HTTP API routes.



37
38
39
# File 'lib/llm/providers/alibaba.rb', line 37

def initialize(host: ENV.fetch("DASHSCOPE_API_HOST", HOST), base_path: BASE_PATH, **)
  super
end

Instance Method Details

#audioObject

Raises:

  • (NotImplementedError)


63
64
65
# File 'lib/llm/providers/alibaba.rb', line 63

def audio
  raise NotImplementedError
end

#default_modelString

Returns the default model for chat completions

Returns:

  • (String)

See Also:



89
90
91
# File 'lib/llm/providers/alibaba.rb', line 89

def default_model
  "deepseek-v4-flash-0731"
end

#error_handlerClass

Returns the class that handles unsuccessful responses

Returns:

  • (Class)

    Returns the class that handles unsuccessful responses



51
52
53
# File 'lib/llm/providers/alibaba.rb', line 51

def error_handler
  LLM::Alibaba::ErrorHandler
end

#imagesObject

Raises:

  • (NotImplementedError)


57
58
59
# File 'lib/llm/providers/alibaba.rb', line 57

def images
  raise NotImplementedError
end

#moderationsObject

Raises:

  • (NotImplementedError)


69
70
71
# File 'lib/llm/providers/alibaba.rb', line 69

def moderations
  raise NotImplementedError
end

#nameSymbol

Returns the provider's name

Returns:

  • (Symbol)

    Returns the provider's name



44
45
46
# File 'lib/llm/providers/alibaba.rb', line 44

def name
  :alibaba
end

#responsesObject

Raises:

  • (NotImplementedError)


75
76
77
# File 'lib/llm/providers/alibaba.rb', line 75

def responses
  raise NotImplementedError
end

#vector_storesObject

Raises:

  • (NotImplementedError)


81
82
83
# File 'lib/llm/providers/alibaba.rb', line 81

def vector_stores
  raise NotImplementedError
end