Skip to main content

Python SDK for AI Teammate - Build and deploy AI agents

Project description

AI Teammate Python SDK

Official Python SDK for AI Teammate - Build and deploy AI agents with ease.

v0.2.3 — Agent document upload (shared RAG knowledge)

Installation

pip install ai-teammate

Getting Started

Step 1: Sign Up

  1. Go to ai-teammate.net
  2. Sign up with Google or Kakao

Step 2: Get API Key

  1. Go to Settings (top-right)
  2. Select API Keys tab
  3. Click Generate New Key
  4. Copy the key (at_xxxx... format)

API keys are shown only once. Store it securely!

Step 3: Install & Create Your First Agent

pip install ai-teammate
from ai_teammate import AITeammate

client = AITeammate(api_key="at_your_key_here")

# Create an agent
agent = client.agents.create(
    name="My First Agent",
    system_prompt="You are a helpful assistant that speaks Korean.",
)
print(f"Agent created: {agent.id}")

# Chat with the agent
response = client.chat("Hello!", agent_id=agent.id)
print(response.content)

Step 4: Check on Portal

Agents created via SDK appear on the portal dashboard.


Features

Agent Management

# List all agents
agents = client.agents.list()

# Create an agent
agent = client.agents.create(
    name="My Assistant",
    system_prompt="You are a helpful assistant.",
)

# Update an agent
agent = client.agents.update(
    agent_id="abc123",
    name="Updated Name",
    system_prompt="New prompt",
)

# Delete an agent
client.agents.delete("abc123")

Agent Documents (Shared RAG Knowledge)

Upload documents directly to an agent. These become shared knowledge available to all users chatting with the agent (via direct chat or share links).

# Upload a document (pdf, txt, md, docx, csv)
doc = client.agents.upload_document("abc123", "./menu.txt")
print(f"Uploaded: {doc.filename} ({doc.chunk_count} chunks)")

# List documents
docs = client.agents.list_documents("abc123")
for d in docs:
    print(f"{d.filename} ({d.chunk_count} chunks)")

# Delete a document
client.agents.delete_document("abc123", doc.id)

Agent documents vs Share documents: Agent documents (agents.upload_document) are shared knowledge for all users. Share documents (shares.upload_document) are per-user uploads scoped to a share link session.

Chat

# Simple chat
response = client.chat("What's the weather?", agent_id="abc123")
print(response.content)

# Streaming chat
for chunk in client.chat_stream("Tell me a story", agent_id="abc123"):
    if chunk.type == "text":
        print(chunk.content, end="", flush=True)

# Conversation context
context = []
response = client.chat("My name is Alice", agent_id="abc123")
context.append({"role": "user", "content": "My name is Alice"})
context.append({"role": "assistant", "content": response.content})

response = client.chat("What's my name?", agent_id="abc123", context=context)
print(response.content)  # "Alice"

Team Chat

# Create a team
team = client.teams.create(
    name="Dream Team",
    chat_mode="brainstorm",  # auto, round_robin, parallel, debate, brainstorm, expert
)

# Add agents to team
client.teams.add_agent(team.id, "agent_1")
client.teams.add_agent(team.id, "agent_2")

# Team chat (multi-agent discussion)
response = client.teams.chat(team.id, "Brainstorm startup ideas!")
print(response.summary)

for r in response.responses:
    print(f"[{r.agent_name}] {r.content}")

Team Chat Modes

Mode Description
round-robin Agents respond sequentially, referencing previous opinions
parallel All agents respond independently
debate Pro/con discussion between agents
brainstorm Idea generation with voting
expert Auto-selects the best agent for the question

Share Links

Share your agent with external users via a link. Supports end-user authentication, file upload, and document-based RAG chat.

# Create a share link
share = client.shares.create(
    agent_id="abc123",
    require_sign_in=True,       # Require end-user authentication
    allow_file_upload=True,     # Allow visitors to upload documents
    include_memory=False,       # Share agent memory with visitors
    max_messages=100,           # Message limit (0 = unlimited)
    expires_in_days=30,         # Link expiration (None = permanent)
)
print(f"Share URL: https://ai-teammate.net{share.share_url}")

# Get share info
info = client.shares.get_info(share.share_code)
print(f"Agent: {info.agent.name}")
print(f"File upload: {info.share.allow_file_upload}")

# Chat via share link
response = client.shares.chat(share.share_code, "Hello!")
print(response.content)

# Upload a document (triggers RAG indexing)
doc = client.shares.upload_document(share.share_code, "./report.pdf")
print(f"Uploaded: {doc.filename} ({doc.chunk_count} chunks)")

# Chat about the document (RAG search)
response = client.shares.chat(share.share_code, "Summarize the report")
print(response.content)  # Agent answers using uploaded document

# List / delete share links
shares = client.shares.list("abc123")
client.shares.delete("abc123", share.id)

Full Flow: Create Agent → Share → Upload → RAG Chat

from ai_teammate import AITeammate

client = AITeammate(api_key="at_your_api_key")

# 1. Create an agent
agent = client.agents.create(
    name="Customer Support Bot",
    system_prompt="You are a friendly customer support agent.",
)

# 2. Create a share link
share = client.shares.create(
    agent_id=agent.id,
    allow_file_upload=True,
    require_sign_in=False,
    max_messages=100,
)
print(f"Share URL: https://ai-teammate.net{share.share_url}")

# 3. Upload FAQ document
doc = client.shares.upload_document(share.share_code, "./faq.pdf")
print(f"Indexed: {doc.chunk_count} chunks")

# 4. Chat — agent answers using the uploaded document
response = client.shares.chat(share.share_code, "What is the refund policy?")
print(response.content)

Memories

# Add memory to agent
memory = client.memories.create(
    agent_id="abc123",
    content="User prefers concise responses",
    category="preferences",
)

# List memories
memories = client.memories.list(agent_id="abc123")

# Search memories
results = client.memories.search(agent_id="abc123", query="preferences")

API Key Types

Type Issued From Scope
Global Settings page All operations
Agent-scoped Agent settings Chat, read, memory for that agent only
Team-scoped Team settings Chat, read for that team only

Agent/Team scoped keys are useful for embedding agents in external apps with restricted access.

Async Support

All methods have async versions prefixed with a:

import asyncio

async def main():
    async with AITeammate(api_key="at_xxx") as client:
        # Async chat
        response = await client.achat("Hello!", agent_id="abc123")

        # Async streaming
        async for chunk in client.achat_stream("Tell me a story", agent_id="abc123"):
            print(chunk.content, end="")

asyncio.run(main())

Error Handling

from ai_teammate import (
    AITeammateError,
    AuthenticationError,
    RateLimitError,
    NotFoundError,
)

try:
    response = client.chat("Hello!", agent_id="invalid_id")
except NotFoundError as e:
    print(f"Agent not found: {e}")
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after} seconds")
except AuthenticationError as e:
    print(f"Invalid API key: {e}")
except AITeammateError as e:
    print(f"Error: {e}")

Configuration

client = AITeammate(
    api_key="at_xxx",
    base_url="https://ai-teammate.net/api",  # Custom API URL
    timeout=30.0,  # Request timeout in seconds
)

API Reference

Client Methods

Method Description
chat(message, agent_id) Chat with an agent
chat_stream(message, agent_id) Stream chat response
achat(message, agent_id) Async chat
achat_stream(message, agent_id) Async stream

Resources

Resource Methods
agents list, get, create, update, delete, upload_document, list_documents, delete_document
teams list, get, create, delete, add_agent, remove_agent, list_agents, chat
memories list, get, create, delete, search
shares create, list, delete, get_info, chat, upload_document, get_history

License

MIT License - see LICENSE for details.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ai_teammate-0.2.3.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ai_teammate-0.2.3-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file ai_teammate-0.2.3.tar.gz.

File metadata

  • Download URL: ai_teammate-0.2.3.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for ai_teammate-0.2.3.tar.gz
Algorithm Hash digest
SHA256 90e7ec135e2f948c2219b0726cd5b0c27d9e26dfa9e77c126e1b8d8a215abacf
MD5 32800f5c2c9dccece73dd00ff86a737c
BLAKE2b-256 58a459bcefa66df9458a0153d91da9bca88b901e9b143b6d4d856203e8b18f24

See more details on using hashes here.

File details

Details for the file ai_teammate-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: ai_teammate-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for ai_teammate-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2b3ebd4cd31121c6836df35972fc9b48e3fa70b688d8b384b79be0ef1b6b33cc
MD5 a4e99134a687b90fbf948e0f9815b018
BLAKE2b-256 ae7f7faa03abfca21996ed7288dc1427df135151742c757bc490d791a6cb26a1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page