Expand description
§ThreatFlux Vertex Rust SDK
A Rust SDK for Google Cloud Vertex AI API, providing access to Gemini models and other AI services.
§Features
- Authentication:
OAuth2, Service Account, and Application Default Credentials - Gemini Models: Content generation with streaming and non-streaming support
- Function Calling: Tool/function calling capabilities
- Token Counting: Count tokens in content
- Chat Completions: Multi-turn conversations
§Quick Start
use threatflux_vertex_rust_sdk::{config::Config, GenerateContentRequest, VertexClient};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = Config {
project_id: "your-project-id".into(),
region: "us-central1".into(),
..Config::default()
};
let client = VertexClient::new(config).await?;
let request = GenerateContentRequest::new("Why is the sky blue?");
let response = client.generate_content("gemini-2.5-flash", &request).await?;
if let Some(text) = response.text() {
println!("Response: {}", text);
}
Ok(())
}Re-exports§
pub use api::chat::ChatConversation;pub use api::embeddings::EmbeddingInstance;pub use api::embeddings::EmbeddingParameters;pub use api::embeddings::EmbeddingPrediction;pub use api::embeddings::EmbeddingRequest;pub use api::embeddings::EmbeddingResponse;pub use api::embeddings::EmbeddingTaskType;pub use api::embeddings::EmbeddingValues;pub use api::embeddings::EmbeddingsApi;pub use api::generate::GenerateApi;pub use api::models::ListLocationsResponse;pub use api::models::ListModelsResponse;pub use api::models::Location;pub use api::models::Model;pub use api::models::ModelsApi;pub use auth::from_env;pub use auth::ApplicationDefaultCredentials;pub use auth::AuthProvider;pub use auth::EnvAuth;pub use auth::ServiceAccountAuth;pub use builders::ContentRequestBuilder;pub use builders::FunctionBuilder;pub use builders::TokenCountBuilder;pub use cache::CacheApi;pub use cache::CacheUsageMetadata;pub use cache::CachedContent;pub use cache::CachedContentRef;pub use cache::CreateCachedContentRequest;pub use cache::ListCachedContentsResponse;pub use cache::UpdateCachedContentRequest;pub use client::VertexClient;pub use client::VertexClientBuilder;pub use error::Result;pub use error::VertexError;pub use media::classify_inline_data;pub use media::InlineDataClassification;pub use media::InlineDataKind;pub use model_descriptor::ModelDescriptor;pub use model_info::get_model_info;pub use model_info::ModelInfo;pub use streaming::ChatStream;pub use streaming::ChatStreamChunk;pub use streaming::SseParser;pub use crate as threatflux_vertex_rust_sdk;pub use models::*;pub use types::*;
Modules§
- api
- API implementations for Vertex AI
- auth
- builders
- Builder patterns for constructing API requests
- cache
- Context caching functionality for Vertex AI
- chat_
core - Shared chat utilities used by the CLI binary and examples.
- claude
- Claude (Anthropic) specific types and helpers for Vertex AI integrations.
- client
- Vertex AI client implementation
- config
- error
- Error types for the Vertex Rust SDK
- media
- model_
descriptor - model_
info - Static model metadata used by higher-level clients.
- models
- Request and response models for Vertex AI API
- streaming
- Server-Sent Events (SSE) streaming support
- streaming_
support - types
Constants§
- DEFAULT_
ENDPOINT - The default API endpoint for Vertex AI
- VERSION
- The current version of the SDK
Functions§
- user_
agent - User agent string for HTTP requests