Enum ApiEndpoint
pub enum ApiEndpoint {
GoogleAI {
api_key: String,
},
GoogleAIToken {
access_token: String,
},
VertexAI(VertexConfig),
}Expand description
API endpoint selector — Google AI (direct), Google AI with OAuth token, or Vertex AI.
§Google AI with API Key (default)
Uses an API key passed as a query parameter. The WebSocket URL is
wss://generativelanguage.googleapis.com/ws/...?key={api_key} and model
URIs are models/{model}.
§Google AI with Access Token
Uses an OAuth2 access token (e.g. from gcloud auth print-access-token)
passed as a query parameter. Same endpoint as Google AI but with
access_token instead of key. This is the recommended approach when
using gcloud credentials without an API key.
§Vertex AI
Uses a regional endpoint with OAuth2 bearer-token authentication. The
WebSocket URL is
wss://{location}-aiplatform.googleapis.com/ws/google.cloud.aiplatform.v1.LlmBidiService/BidiGenerateContent
and model URIs are
projects/{project}/locations/{location}/publishers/google/models/{model}.
let google_ai = ApiEndpoint::google_ai("MY_API_KEY");
let with_token = ApiEndpoint::google_ai_token("ya29.ACCESS_TOKEN");
let vertex = ApiEndpoint::vertex("my-project", "us-central1", "ACCESS_TOKEN");Variants§
GoogleAI
Google AI Studio – API-key authentication.
GoogleAIToken
Google AI with OAuth2 access token (e.g. from gcloud).
VertexAI(VertexConfig)
Vertex AI — project + location + OAuth2 bearer token.
Implementations§
§impl ApiEndpoint
impl ApiEndpoint
pub fn google_ai(api_key: impl Into<String>) -> ApiEndpoint
pub fn google_ai(api_key: impl Into<String>) -> ApiEndpoint
Shorthand for Google AI endpoint with API key.
pub fn google_ai_token(access_token: impl Into<String>) -> ApiEndpoint
pub fn google_ai_token(access_token: impl Into<String>) -> ApiEndpoint
Google AI endpoint with an OAuth2 access token.
Use this when authenticating with gcloud auth print-access-token
or any other OAuth2 flow instead of an API key.
pub fn vertex(
project: impl Into<String>,
location: impl Into<String>,
access_token: impl Into<String>,
) -> ApiEndpoint
pub fn vertex( project: impl Into<String>, location: impl Into<String>, access_token: impl Into<String>, ) -> ApiEndpoint
Shorthand for Vertex AI endpoint.
pub fn vertex_with_host(
project: impl Into<String>,
location: impl Into<String>,
access_token: impl Into<String>,
api_host: impl Into<String>,
) -> ApiEndpoint
pub fn vertex_with_host( project: impl Into<String>, location: impl Into<String>, access_token: impl Into<String>, api_host: impl Into<String>, ) -> ApiEndpoint
Vertex AI endpoint with a custom API host (for private endpoints, VPC-SC, or testing).
Trait Implementations§
§impl Clone for ApiEndpoint
impl Clone for ApiEndpoint
§fn clone(&self) -> ApiEndpoint
fn clone(&self) -> ApiEndpoint
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more