from openai import OpenAI, APIError, RateLimitError, AuthenticationError
client = OpenAI(base_url="https://kymaapi.com/v1", api_key="ky-your-api-key")
try:
response = client.chat.completions.create(
model="llama-3.3-70b",
messages=[{"role": "user", "content": "Hello"}]
)
except AuthenticationError:
print("Invalid API key")
except RateLimitError:
print("Daily limit reached. Try again tomorrow.")
except APIError as e:
print(f"API error: {e.message}")