Metadata-Version: 2.4
Name: gtwy-sdk
Version: 0.6.0
Summary: Official Python SDK for the GTWY API — build and call agentic AI, RAG, and LLM-powered agents
Author: GTWY
License: MIT
Project-URL: Homepage, https://gtwy.ai
Keywords: gtwy,ai,llm,agents,agentic ai,rag,chatbot,sdk,api client
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests<3,>=2.25
Dynamic: license-file

# gtwy-sdk

Official Python client for the GTWY API — build and call agentic AI, RAG,
and LLM-powered agents.

```bash
pip install gtwy-sdk
```

```python
from gtwy import Gtwy

client = Gtwy(auth_key="<authKey>")

response = client.chat.completions.create(
    agent_id="my-agent-id",
    user="What's the capital of France?",
)
print(response.content)
```

`auth_key` is the key you get from the GTWY platform (labeled `authkey`
there). It can also come from the `GTWY_AUTH_KEY` environment variable. If
you hold a GTWY session token instead of a pauthkey, pass `authorization`
instead of `auth_key` (exactly one of the two is required).
`base_url` defaults to `https://api.gtwy.ai`; override it (constructor arg or
`GTWY_BASE_URL`) to point at a different environment.

## Creating and configuring agents

```python
# Create an agent and wait for it to come back inline
created = client.agent.create(purpose="A support bot for order tracking", flag=True)
agent_id = created.agent["_id"]

# Configure its (auto-created) first version
version_id = created.agent["versions"][0]
client.version.update(
    version_id,
    configuration={"model": "gpt-4o", "prompt": "You are a helpful support assistant."},
    service="openai",
)

# Publish it, making it live
client.version.publish(version_id)

# Rename the agent (or update any other field — see SKILLS.md)
client.agent.update(agent_id, name="Order Support Bot")
```

Keyword arguments for `agent`/`version`/`tools`/`knowledge_base`/`apikey`
are sent through exactly as given — no snake_case translation — so field
names must match what the GTWY API expects (`folder_id`, `version_id`,
`api_config`, etc., but also mixed-case ones like `templateId` where the
API itself uses camelCase); see `SKILLS.md` for the full field list per
method.

See [gtwy/SKILLS.md](./gtwy/SKILLS.md) for the full reference: every resource
(`chat`, `batch`, `rerun`, `agent`, `version`, `tools`, `knowledge_base`,
`apikey`), every request field, response shapes, delivery modes
(sync/webhook), and error handling. This file
ships **inside** the installed package (not just this repo) — after
`pip install gtwy-sdk` it's reachable at `gtwy.SKILLS_PATH` /
`gtwy.get_skills_doc()`, so an AI agent (e.g. Claude) can read it and use
this SDK correctly without ever cloning this repo.

## Embed: acting for your own end users

You are given an embed access key, your org id and an embed folder id (set up
in GTWY, not through this SDK). Sign a token for each end user on your server
and use it as the credential:

```python
from gtwy import Gtwy, create_embed_token

embed_token = create_embed_token(
    access_key=access_key, org_id=org_id, folder_id=folder_id,
    unique_identifier="cus_42", name="Asha Rao", email="asha@example.com",  # name/email -> meta
    expires_in=3600,
)
user = Gtwy(embed_token=embed_token)                # or GTWY_EMBED_TOKEN
agents = user.agent.list().agents                   # only this user's agents
user.agent.update(agents[0]["_id"], name="Renamed")
```

An embed token works for agents, versions, tools, documents and the embed
calls, but **not** for `chat`/`batch`/`rerun`: those accept only the org's
`auth_key`, so call them from your server (the SDK raises before sending
otherwise). There is no separate embed resource: the normal `agent`, `version`,
`tools` and `knowledge_base` calls are scoped to the user. See "Embed" in `SKILLS.md`.

## Development

```bash
pip install -e .
```
