Skip to main content

giskard-llm

Lightweight LLM routing layer over native provider SDKs. Routes provider/model strings to the correct async SDK (OpenAI, Google Gemini, Anthropic, Azure OpenAI, Azure AI Foundry).

Installation

pip install giskard-llm[openai]      # OpenAI + Azure OpenAI + Azure AI Foundry
pip install giskard-llm[google]      # Google Gemini
pip install giskard-llm[anthropic]   # Anthropic
pip install giskard-llm[all]         # All providers

Note: Azure OpenAI (azure/) and Azure AI Foundry (azure_ai/) use the openai SDK. Installing giskard-llm[openai] (or giskard-llm[azure]) covers all three.

Quick start

from giskard.llm import acompletion, aembedding

# Module-level functions use env vars automatically
response = await acompletion(
    model="openai/gpt-4o",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)

# Bare model names default to OpenAI
response = await acompletion(model="gpt-4o", messages=[...])

LLMClient (programmatic configuration)

from giskard.llm import LLMClient

client = LLMClient()

# Configure with explicit values or env var references
client.configure("openai", api_key="sk-...")  # pragma: allowlist secret
client.configure(
    "azure-prod",
    provider="azure",
    api_key="os.environ/AZURE_PROD_KEY",  # pragma: allowlist secret
    base_url="os.environ/AZURE_PROD_ENDPOINT",
    api_version="2024-02-01",
)
client.configure(
    "anthropic-relaxed",
    provider="anthropic",
    api_key="os.environ/ANTHROPIC_API_KEY",  # pragma: allowlist secret
    merge_system=True,
)

response = await client.acompletion("azure-prod/gpt-4o", messages)
response = await client.acompletion(
    "anthropic-relaxed/claude-3-5-haiku-latest", messages
)

Provider reference

Prefix SDK Auth env var Completion Embeddings Notable kwargs
openai/ (default) openai OPENAI_API_KEY yes yes base_url, timeout, http_client, default_headers
google/ google-genai GOOGLE_API_KEY / GEMINI_API_KEY yes yes http_client, default_headers, http_options
anthropic/ anthropic ANTHROPIC_API_KEY yes no merge_system, timeout, http_client (httpx2, see below), default_headers
azure/ openai AZURE_API_KEY, AZURE_API_BASE yes yes api_version, base_url, http_client, default_headers
azure_ai/ openai AZURE_AI_API_KEY, AZURE_AI_ENDPOINT yes model-dependent base_url, http_client, default_headers

Structured output schemas

Pydantic response_format models are converted in each provider's translator. OpenAI and Azure close object schemas recursively while preserving explicit additionalProperties schemas on dict[str, X] fields. Anthropic uses its SDK's transform_schema; that SDK converts dict[str, X] fields to closed objects with no declared properties, so avoid map fields in Anthropic structured output models.

Azure Foundry OpenAI v1

Azure Foundry OpenAI v1 endpoints are OpenAI-compatible. Configure them with the openai provider and the Azure /openai/v1/ base URL. Use Azure deployment names as the chat, response, and embedding model names.

from giskard.llm import LLMClient

client = LLMClient()
client.configure(
    "foundry-v1",
    provider="openai",
    api_key="os.environ/AZURE_OPENAI_API_KEY",  # pragma: allowlist secret
    base_url="https://example.openai.azure.com/openai/v1/",
)

chat = await client.acompletion(
    "foundry-v1/gpt-4.1-mini",
    [{"role": "user", "content": "Write one sentence."}],
)
response = await client.aresponse("foundry-v1/gpt-4.1-mini", "Write one sentence.")
embedding = await client.aembedding(
    "foundry-v1/text-embedding-3-small",
    ["Text to embed."],
)

Use azure/ for classic Azure OpenAI deployments that require api_version. Use azure_ai/ for the existing Azure AI Foundry compatibility path. Do not use azure_ai/ for new OpenAI v1 endpoints unless you intentionally need that legacy endpoint behavior.

Custom transport and headers

Use http_client to provide a caller-owned async HTTP client, for example when your environment requires a custom CA bundle. giskard-llm passes this client through to provider SDKs and does not close it.

import httpx
from giskard.llm import LLMClient

http_client = httpx.AsyncClient(verify="/path/to/ca.pem")

client = LLMClient()
client.configure(
    "azure-secure",
    provider="azure_ai",
    api_key="os.environ/AZURE_AI_API_KEY",  # pragma: allowlist secret
    base_url="os.environ/AZURE_AI_ENDPOINT",
    http_client=http_client,
    default_headers={"x-ms-useragent": "giskard-llm"},
)
client.configure(
    "google-secure",
    provider="google",
    api_key="os.environ/GEMINI_API_KEY",  # pragma: allowlist secret
    http_client=http_client,
)

response = await client.acompletion("azure-secure/gpt-4.1-nano", messages)
await http_client.aclose()

The anthropic provider is the exception. Anthropic SDK v1 requires an httpx2.AsyncClient and raises a TypeError for an httpx.AsyncClient.

import httpx2

anthropic_http_client = httpx2.AsyncClient(verify="/path/to/ca.pem")
client.configure(
    "anthropic-secure",
    provider="anthropic",
    api_key="os.environ/ANTHROPIC_API_KEY",  # pragma: allowlist secret
    http_client=anthropic_http_client,
)

For detailed per-provider documentation (role mapping, message constraints, tool format, error mapping), see the provider class docstrings in src/giskard/llm/providers/.

Metadata

Release files for giskard-llm 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for giskard-llm 1.0.3
File Size Uploaded Provenance
giskard_llm-1.0.3.tar.gz 68.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for giskard-llm 1.0.3
File Interpreter ABI Platform
giskard_llm-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 114.6 kB

Release files / giskard_llm-1.0.3.tar.gz

Download URL giskard_llm-1.0.3.tar.gz
Size 68.9 kB
Tags Source
SHA-256 checksum
How to use checksums
10da78035afc606424d9adaf063eb5e9d672d68043fe839706467df8083c797d
BLAKE2b-256 checksum
How to use checksums
598977418f8bdfdf3ad79cebbe700c14bcfd0c0375e93468daa1d2b61331cfdf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.3 {"installer":{"name":"uv","version":"0.13.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / giskard_llm-1.0.3-py3-none-any.whl

Download URL giskard_llm-1.0.3-py3-none-any.whl
Size 45.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
527f305579d539021c365f2869de0bbf7808609d46b301de14c2e3ca2625e58e
BLAKE2b-256 checksum
How to use checksums
924801d5038b68fbe70f3c979629c9cfddf3887f4f5059a1671e02cfac7b387b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.3 {"installer":{"name":"uv","version":"0.13.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for giskard-llm 1.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page