Agenta SDK

raw JSON →
0.96.10 verified Fri May 01 auth: no python

Agenta is an open-source LLMOps platform for prompt engineering, evaluation, and deployment. The `agenta` Python SDK (v0.96.10) integrates with your LLM applications to manage prompts, track variants, run evaluations, and collect observability data. Requires Python >=3.11, <4.0. Active development with frequent releases.

pip install agenta
error ImportError: cannot import name 'prompt' from 'agenta'
cause The `prompt` submodule is not directly importable in older SDK versions or if the SDK version is <0.96.0.
fix
Upgrade to agenta >=0.96.0 and use from agenta import prompt. If using an older version, use from agenta.sdk import prompt or check the docs.
error agenta.exceptions.AgentaAPIError: 404 Not Found: The requested variant does not exist.
cause The app_slug or variant name is incorrect, or the variant has not been deployed in the Agenta platform.
fix
Verify the app_slug and variant name in the Agenta UI. Ensure the variant is deployed (status 'deployed'). Check the host URL.
error RuntimeError: You must call agenta.init() before using this feature.
cause Tracing or prompt calls were attempted before initializing the SDK.
fix
Add agenta.init(api_key=..., host=...) at the beginning of your code, before any other agenta calls.
error AttributeError: module 'agenta' has no attribute 'init'
cause An older version of agenta (<0.96.0) uses a different initialization pattern (e.g., `agenta.init_app()` or `agenta.sdk.init()`).
fix
Upgrade to agenta >=0.96.0 with pip install agenta --upgrade. For older versions, check the docs for the correct init method.
breaking In v0.96.0 the REST API endpoints changed significantly. The old `/configs/fetch` endpoint was replaced by a new unified invoke API. If you were using the HTTP API directly, update your requests.
fix Migrate to the new invoke API: use POST /api/v1/apps/{app_id}/variants/{variant_id}/invoke with {'inputs': ...}. See migration guide at https://docs.agenta.ai.
breaking The SDK version 0.96.0 dropped support for Python <3.11. Ensure your environment uses Python 3.11 or later.
fix Upgrade Python to 3.11+ or pin agenta <0.96.0 if you must use an older Python.
breaking `ag.init()` (or `agenta.init()`) must be called before any tracing or prompt calls. In older versions, tracing could work without init; now it raises a warning (v0.96.3) and may fail in future versions.
fix Always call `agenta.init(api_key=..., host=...)` at the start of your application.
deprecated The `variant/configs/fetch` legacy adapter was re-added in v0.96.2 as a backward-compatibility bridge, but will be removed in a future release. Use the new invoke API instead.
fix Replace any calls to `/variant/configs/fetch` with the new unified invoke endpoint.
gotcha Environment variable `AGENTA_API_KEY` must be set before calling `agenta.init()`. If not set, the SDK may fail silently or raise an unclear error.
fix Set the environment variable in your shell or pass `api_key` explicitly: `agenta.init(api_key='...')`.

Initialize the SDK and call a prompt from a deployed variant.

import agenta
import os

# Initialize with API key (set AGENTA_API_KEY environment variable)
agenta.init(
    api_key=os.environ.get("AGENTA_API_KEY", ""),
    host="http://localhost:3000"  # Default self-hosted URL
)

# Simple prompt call (requires a deployed variant in the Agenta platform)
from agenta import prompt

response = prompt.call(
    app_slug="my-app",
    variant="default",
    inputs={"topic": "AI"}
)
print(response)