Expand description
§GPT-5 Rust Client Library
A comprehensive Rust client library for OpenAI’s GPT-5 API with support for:
- Function calling and tool usage
- Reasoning capabilities with configurable effort levels
- Verbosity control for response detail
- Streaming and non-streaming responses
- Type-safe enums for all API parameters
§Quick Start
use gpt5::{Gpt5Client, Gpt5Model, Gpt5RequestBuilder, VerbosityLevel};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Gpt5Client::new("your-api-key".to_string());
let response = client
.simple(Gpt5Model::Gpt5Nano, "Hello, world!")
.await?;
println!("Response: {}", response);
Ok(())
}
§Advanced Usage with Function Calling
use gpt5::{Gpt5Client, Gpt5Model, Gpt5RequestBuilder, Tool};
use serde_json::json;
let weather_tool = Tool {
tool_type: "function".to_string(),
name: Some("get_weather".to_string()),
description: Some("Get current weather".to_string()),
parameters: Some(json!({
"type": "object",
"properties": {
"location": {"type": "string", "description": "City name"}
},
"required": ["location"]
})),
};
let req = Gpt5RequestBuilder::new(Gpt5Model::Gpt5)
.input("What's the weather in Boston?")
.tools(vec![weather_tool])
.tool_choice("auto")
.build();
Structs§
- Gpt5
Client - Main client for interacting with the GPT-5 API
- Gpt5
Request - Request structure for the GPT-5 /v1/responses endpoint
- Gpt5
Request Builder - Builder for GPT-5 requests using /v1/responses
- Gpt5
Response - Response structure from /v1/responses
- Input
Token Details - Input token details
- Open
AiError - Error response structure from OpenAI
- Open
AiError Details - Error details
- Output
Content - Content within an output message
- Request
Reasoning - Reasoning configuration for requests
- Request
Text - Text configuration for requests
- Response
Output - Output content in the response
- Response
Reasoning - Reasoning information in the response
- Response
Text - Text formatting information
- Response
Text Format - Text format specification
- Response
Token Details - Output token details
- Response
Usage - Token usage statistics
- Tool
- Tool definition for function calling
- WebSearch
Config - Configuration for enabling web search assistance.
Enums§
- Content
Type - Content type for output content
- Format
Type - Format type for text responses
- Gpt5
Model - GPT-5 Models available for the /v1/responses endpoint
- Output
Type - Output type for GPT-5 responses
- Reasoning
Effort - Reasoning effort level for GPT-5 responses
- Role
- Role in the conversation
- Status
- Response status for GPT-5 responses
- Verbosity
Level - Verbosity level for GPT-5 responses