Skip to main content

Module openai

Module openai 

Source
Expand description

OpenAI-compatible API client.

Works with any provider that implements the OpenAI Chat Completions API with streaming: OpenAI itself, DeepSeek, Grok, Ollama (via the ollama() constructor in the parent module), vLLM, LM Studio, etc.

§Construction

use loopctl::provider::OpenAiClient;

// From environment (OPENAI_API_KEY, optional OPENAI_BASE_URL):
let client = OpenAiClient::from_env()?;

// Explicit:
let client = OpenAiClient::builder()
    .with_api_key("sk-...")
    .with_base_url("https://api.deepseek.com/v1")
    .with_model("deepseek-chat")
    .build()?;

Structs§

OpenAiClient
An OpenAI-compatible chat completions client with streaming support.
OpenAiClientBuilder
Builder for OpenAiClient.