1414from openai .types .chat .chat_completion_message import ChatCompletionMessage
1515from openai .types .chat .chat_completion_message_tool_call import ChatCompletionMessageToolCall , Function
1616from any_llm .provider import Provider , ApiConfig
17+ from any_llm .exceptions import MissingApiKeyError
1718
1819DEFAULT_TEMPERATURE = 0.7
1920
@@ -196,8 +197,10 @@ def __init__(self, config: ApiConfig) -> None:
196197 self .location = os .getenv ("GOOGLE_REGION" , "us-central1" )
197198
198199 if not self .project_id :
199- msg = "GOOGLE_PROJECT_ID environment variable is required for Vertex AI"
200- raise ValueError (msg )
200+ raise MissingApiKeyError (
201+ "Google Vertex AI" ,
202+ "GOOGLE_PROJECT_ID" ,
203+ )
201204
202205 # Initialize client for Vertex AI
203206 self .client = genai .Client (vertexai = True , project = self .project_id , location = self .location )
@@ -207,8 +210,10 @@ def __init__(self, config: ApiConfig) -> None:
207210 api_key = getattr (config , "api_key" , None ) or os .getenv ("GEMINI_API_KEY" ) or os .getenv ("GOOGLE_API_KEY" )
208211
209212 if not api_key :
210- msg = "API key is required for Gemini Developer API. Provide it via ApiConfig or set GEMINI_API_KEY/GOOGLE_API_KEY environment variable"
211- raise ValueError (msg )
213+ raise MissingApiKeyError (
214+ "Google Gemini Developer API" ,
215+ "GEMINI_API_KEY/GOOGLE_API_KEY" ,
216+ )
212217
213218 # Initialize client for Gemini Developer API
214219 self .client = genai .Client (api_key = api_key )
0 commit comments