AI SDK OpenAI - Rust Implementation
OpenAI provider implementation for the AI SDK in Rust. This crate provides a unified interface for interacting with OpenAI's models including GPT, DALL-E, Whisper, and Embeddings.
Features
- 🤖 Chat Completion - GPT-4, GPT-3.5 and other chat models
- 🔢 Embeddings - text-embedding-3-small, text-embedding-3-large
- 🖼️ Image Generation - DALL-E 2 and DALL-E 3
- 🗣️ Speech Synthesis - Text-to-speech with OpenAI TTS
- 👂 Transcription - Speech-to-text with Whisper
- 🔄 Streaming - Stream responses for real-time applications
- 🛠️ Tool Calling - Function calling support for chat models
Installation
Add this to your Cargo.toml:
[]
= "0.1"
= "0.1"
Quick Start
Chat Completion
use OpenAIChatModel;
use ;
async
Embeddings
use OpenAIEmbeddingModel;
use EmbeddingModel;
async
Image Generation
use OpenAIImageModel;
use ;
async
Supported Models
Chat Models
gpt-4- Most capable GPT-4 modelgpt-4-turbo- GPT-4 Turbo with improved performancegpt-3.5-turbo- Fast and efficient model
Embedding Models
text-embedding-3-small- Smaller, faster embedding modeltext-embedding-3-large- Larger, more accurate embedding model
Image Models
dall-e-2- DALL-E 2 image generationdall-e-3- DALL-E 3 with improved quality
Speech Models
tts-1- Standard text-to-speechtts-1-hd- High-definition text-to-speechwhisper-1- Speech-to-text transcription
Documentation
Repository
This crate is part of the AI SDK for Rust workspace.
Contributing
We welcome contributions! Please see the Contributing Guide for guidelines.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.