Created
June 26, 2025 16:05
-
-
Save samuelcolvin/00592e726f745a719ab74a4866eef924 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /// script | |
# requires-python = ">=3.12" | |
# dependencies = [ | |
# "logfire", | |
# "pydantic-ai-slim[google]", | |
# ] | |
# /// | |
import logfire | |
from pydantic_ai import Agent | |
logfire.configure() | |
logfire.instrument_pydantic_ai() | |
agent = Agent('google-vertex:gemini-2.5-flash') | |
r = agent.run_sync('what is 1 + 1') | |
print(r.output) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /// script | |
# requires-python = ">=3.12" | |
# dependencies = [ | |
# "google-genai", | |
# "logfire[httpx]", | |
# "opentelemetry-instrumentation-google-genai", | |
# ] | |
# /// | |
import os | |
import logfire | |
from google import genai | |
from opentelemetry.instrumentation.google_genai import GoogleGenAiSdkInstrumentor | |
logfire.configure() | |
# to instrument the raw http requests, uncomment this line: | |
# logfire.instrument_httpx(capture_all=True) | |
os.environ['OTEL_GOOGLE_GENAI_GENERATE_CONTENT_CONFIG_INCLUDES'] = '*' | |
GoogleGenAiSdkInstrumentor().instrument() | |
client = genai.Client(vertexai=True, location='global') | |
response = client.models.generate_content(model='gemini-2.5-flash', contents='what is 1 + 1') | |
print(response.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment