from google import genai
from google.genai import types
client = genai.Client(
http_options={
"base_url": "https://gateway.adaline.ai/v1/google",
"headers": {
"adaline-api-key": "your-adaline-api-key",
"adaline-project-id": "your-project-id",
"adaline-prompt-id": "your-prompt-id",
},
},
api_key="your-google-api-key",
)
stream = client.models.generate_content_stream(
model="gemini-1.5-pro",
contents="You are a helpful assistant.\n\nExplain the concept of machine learning in detail.",
config=types.GenerateContentConfig(
http_options=types.HttpOptions(
headers={
"adaline-trace-name": "google-stream-chat" # Optional
}
)
)
)
for chunk in stream:
if hasattr(chunk, 'text') and chunk.text:
print(chunk.text, end="")