Complete guide to the send() method in the Rust SDK.
The send() method is used to make non-streaming chat completion requests to the Edgee AI Gateway. It returns a Result<SendResponse> with the model’s response.
When input is a string (&str or String), it’s automatically converted to a user message:
Copy
Ask AI
let response = client.send("gpt-5.2", "What is the capital of France?").await?;// Equivalent to: input: InputObject::new(vec![Message::user("What is the capital of France?")])println!("{}", response.text().unwrap_or(""));// "The capital of France is Paris."
When input is an InputObject, you have full control over the conversation:
Property
Type
Description
messages
Vec<Message>
Array of conversation messages
tools
Option<Vec<Tool>>
Array of function tools available to the model
tool_choice
Option<serde_json::Value>
Controls which tool (if any) the model should call. See Tools documentation for details
tags
Option<Vec<String>>
Optional tags to categorize and label the request for analytics and filtering. Can also be sent via the x-edgee-tags header (comma-separated)
compression_model
Option<String>
Compression model for this request: "agentic", "claude", "opencode", "cursor", or "customer". Each model is a bundle of compression strategies. Overrides API key settings when present.
compression_configuration
Option<CompressionConfiguration>
Configuration for the compression model. Currently only available for agentic. Contains optional rate (0.0-1.0, default 0.8) and semantic_preservation_threshold (0-100).
Example with InputObject:
Copy
Ask AI
use edgee::{Message, InputObject};let input = InputObject::new(vec![ Message::user("What is 2+2?")]);let response = client.send("gpt-5.2", input).await?;println!("{}", response.text().unwrap_or(""));// "2+2 equals 4."
Example with Tags:
Copy
Ask AI
use edgee::{Message, InputObject};let input = InputObject::new(vec![ Message::user("Summarize this article")]).with_tags(vec![ "summarization".to_string(), "production".to_string(), "user-123".to_string()]);let response = client.send("gpt-5.2", input).await?;
Reason why the generation stopped. Possible values: "stop", "length", "tool_calls", "content_filter", or None
Example - Handling Multiple Choices:
Copy
Ask AI
let response = client.send("gpt-5.2", "Give me a creative idea.").await?;// Process all choicesfor choice in &response.choices { println!("Choice {}: {:?}", choice.index, choice.message.content); println!("Finish reason: {:?}", choice.finish_reason);}