openai-api-rs  by dongri

Rust SDK for OpenAI API access

created 2 years ago
429 stars

Top 70.2% on sourcepulse

GitHubView on GitHub
Project Summary

This Rust library provides an unofficial client for interacting with the OpenAI API, offering convenient access for Rust developers. It supports a comprehensive range of OpenAI functionalities, including chat completions, image generation, embeddings, and fine-tuning, making it suitable for integrating AI capabilities into Rust applications.

How It Works

The library leverages Rust's strong type system and asynchronous capabilities (via Tokio) to provide a safe and efficient interface to the OpenAI API. It abstracts the HTTP requests and JSON serialization/deserialization, allowing developers to focus on building AI-powered features. The client can be configured with API keys and custom endpoints, including support for services like OpenRouter.

Quick Start & Requirements

  • Install via Cargo: openai-api-rs = "6.0.3"
  • Requires Rust toolchain.
  • Set OPENAI_API_KEY or OPENROUTER_API_KEY environment variable.
  • Example usage and full API documentation available at docs.rs.

Highlighted Details

  • Supports a wide array of OpenAI API endpoints: Completions, Chat, Edits, Images, Embeddings, Audio, Files, Fine-tuning, Moderations, Function calling, Assistants, Batch, and Realtime.
  • Includes examples for both OpenAI and OpenRouter integrations.
  • Demonstrates asynchronous request handling with Tokio.

Maintenance & Community

  • The project is maintained by dongri.
  • Further examples are available in the examples directory.

Licensing & Compatibility

  • Licensed under the MIT license.
  • Permissive license allows for commercial use and integration into closed-source projects.

Limitations & Caveats

This is an unofficial library, meaning it is not directly supported or endorsed by OpenAI. While it aims for comprehensive coverage, new or undocumented API features might not be immediately supported.

Health Check
Last commit

1 week ago

Responsiveness

1 day

Pull Requests (30d)
2
Issues (30d)
2
Star History
29 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.