AI.Providers.OpenAICompatible.ChatLanguageModel (AI SDK v0.0.1-rc.0)

View Source

OpenAI-compatible chat language model implementation.

This module implements the language model interface for OpenAI-compatible APIs.

Summary

Functions

Generate text using the OpenAI-compatible API.

Stream text generation using the OpenAI-compatible API.

Creates a new OpenAI-compatible chat language model.

Functions

do_generate(model, opts)

Generate text using the OpenAI-compatible API.

Options

  • :messages - List of messages to send to the API (required)
  • :temperature - Temperature for sampling (default: 1.0)
  • :max_tokens - Maximum number of tokens to generate (optional)
  • :tools - List of tools available to the model (optional)
  • :tool_choice - Tool choice configuration (optional)
  • :response_format - Response format configuration (optional)

do_stream(model, opts)

Stream text generation using the OpenAI-compatible API.

This function enables streaming responses from the model, returning chunks as they are generated rather than waiting for the complete response.

Options

  • :messages - List of messages to send to the API (required)
  • :temperature - Temperature for sampling (default: 1.0)
  • :max_tokens - Maximum number of tokens to generate (optional)
  • :tools - List of tools available to the model (optional)
  • :tool_choice - Tool choice configuration (optional)
  • :response_format - Response format configuration (optional)

new(provider, opts)

Creates a new OpenAI-compatible chat language model.

Options

  • :model_id - The model ID to use (required)
  • :supports_image_urls - Whether the model supports image URLs (default: false)
  • :supports_structured_outputs - Whether the model supports structured outputs (default: false)