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§
Source§impl ApiEndpoint
impl ApiEndpoint
Sourcepub fn google_ai(api_key: impl Into<String>) -> Self
pub fn google_ai(api_key: impl Into<String>) -> Self
Shorthand for Google AI endpoint with API key.
Sourcepub fn google_ai_token(access_token: impl Into<String>) -> Self
pub fn google_ai_token(access_token: impl Into<String>) -> Self
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.
Trait Implementations§
Source§impl Clone for ApiEndpoint
impl Clone for ApiEndpoint
Source§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