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§
- Open
AiCompat Config - Configuration for an
OpenAiCompatProvider. - Open
AiCompat Provider - OpenAI-compatible
Providerimplementation.
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_KEYfrom the environment. - groq
- Create a Groq provider, reading
GROQ_API_KEYfrom the environment. - mistral
- Create a Mistral provider, reading
MISTRAL_API_KEYfrom the environment. - ollama
- Create a local Ollama provider (no authentication needed).
- openai
- Create an OpenAI provider, reading
OPENAI_API_KEYfrom the environment. - together
- Create a Together AI provider, reading
TOGETHER_API_KEYfrom the environment. - xai
- Create an xAI (Grok) provider, reading
XAI_API_KEYfrom the environment.