Skip to main content
This plugin allows services to connect to OpenAI, enabling easy access to OpenAI’s powerful language models and AI capabilities.

Usage

Add shuttle-openai to the dependencies for your service by running cargo add shuttle-openai. This resource will be provided by adding the shuttle_openai::OpenAI attribute to your Shuttle main decorated function. It returns an async_openai::Client<OpenAIConfig> for you to interact with OpenAI’s services.

Example

In the case of an Axum server, your main function will look like this:
Click here for the full example.

Parameters

The API key is loaded from your Secrets.toml file.

Configuration

To use this integration, you need to set up your OpenAI API key in the Secrets.toml file:
Make sure to keep your API key confidential and never commit it to version control.

Additional Information

For more details on how to use the OpenAI client in your Rust application, refer to the async_openai documentation. Remember to handle API usage responsibly and in accordance with OpenAI’s usage policies and rate limits.