🎁 Get the FREE AI Skills Starter Guide β€” Subscribe β†’
BytesAgainBytesAgain
πŸ¦€ ClawHub

Galileo python sdk

by @gyanesh-m

Complete reference for the Galileo AI platform Python SDK for evaluating, observing, and protecting GenAI applications. Use when building Python applications...

Versionv1.2.1
Comments1
πŸ’‘ Examples

import os
from galileo import galileo_context
from galileo.openai import openai

galileo_context.init(project="my-project", log_stream="my-log-stream")

client = openai.OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))

response = client.chat.completions.create( messages=[{"role": "user", "content": "Explain quantum computing in one sentence."}], model="gpt-4o", )

print(response.choices[0].message.content)

galileo_context.flush()

πŸ“‹ Tips & Best Practices

1. Always set environment variables for GALILEO_API_KEY and GALILEO_CONSOLE_URL rather than hardcoding credentials. 2. Organize projects and log streams by application, environment, or team to keep traces manageable. 3. Call galileo_context.flush() at the end of each request or batch to ensure traces are uploaded. In web servers, flush at the end of each request handler. 4. Use the context manager (with galileo_context(...)) for scoped logging that auto-flushes on exit. 5. Use specific span types (retriever, tool, llm, workflow) to get the most out of Galileo's trace visualization. 6. Handle errors gracefully β€” wrap flush() calls in try/except to prevent logging failures from crashing your application. 7. Use the wrapped OpenAI client (from galileo.openai import openai) for zero-config automatic tracing of all OpenAI calls. 8. Leverage guardrail metrics in production to catch hallucinations, toxic content, and PII before they reach end users.

View on ClawHub
TERMINAL
clawhub install galileo-python-sdk

πŸ§ͺ Use this skill with your agent

Most visitors already have an agent. Pick your environment, install or copy the workflow, then run the smoke-test prompt above.

πŸ” Can't find the right skill?

Search 60,000+ AI agent skills β€” free, no login needed.

Search Skills β†’