Skip to main content

Crate traitclaw_openai

Crate traitclaw_openai 

Source
Expand description

OpenAI provider for the TraitClaw AI agent framework.

Provides ergonomic constructor functions that read API keys from environment variables, plus native OpenAI features like structured output.

§Quick Start

use traitclaw_openai::openai;

// Reads OPENAI_API_KEY from the environment automatically
let provider = openai("gpt-4o-mini");

§Structured Output

use traitclaw_openai::{openai, structured::StructuredOutputProvider};
use schemars::JsonSchema;
use serde::Deserialize;

#[derive(Deserialize, JsonSchema)]
struct Report { summary: String, confidence: f32 }

let provider = StructuredOutputProvider::<Report>::new(openai("gpt-4o-mini"), "report");

Modules§

structured
Native OpenAI structured output support.

Structs§

OpenAiCompatConfig
Configuration for an OpenAiCompatProvider.
OpenAiCompatProvider
OpenAI-compatible Provider implementation.

Functions§

azure_openai
Create an Azure OpenAI provider.
custom
Create a provider for any custom OpenAI-compatible endpoint.
deepseek
Create a DeepSeek provider, reading DEEPSEEK_API_KEY from the environment.
groq
Create a Groq provider, reading GROQ_API_KEY from the environment.
mistral
Create a Mistral provider, reading MISTRAL_API_KEY from the environment.
ollama
Create a local Ollama provider (no authentication needed).
openai
Create an OpenAI provider, reading OPENAI_API_KEY from the environment.
together
Create a Together AI provider, reading TOGETHER_API_KEY from the environment.
xai
Create an xAI (Grok) provider, reading XAI_API_KEY from the environment.