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.

Installation

pip install ai-teammate

๐Ÿš€ Getting Started

Step 1: ํšŒ์›๊ฐ€์ž…

  1. ai-teammate.net ์ ‘์†
  2. Google ๋˜๋Š” Kakao๋กœ ๊ฐ„ํŽธ ๊ฐ€์ž…

Step 2: API ํ‚ค ๋ฐœ๊ธ‰

  1. ๋กœ๊ทธ์ธ ํ›„ ์šฐ์ธก ์ƒ๋‹จ Settings ํด๋ฆญ
  2. API Keys ํƒญ ์„ ํƒ
  3. Generate New Key ํด๋ฆญ
  4. ์ƒ์„ฑ๋œ ํ‚ค ๋ณต์‚ฌ (at_xxxx... ํ˜•์‹)

โš ๏ธ API ํ‚ค๋Š” ํ•œ ๋ฒˆ๋งŒ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค. ์•ˆ์ „ํ•œ ๊ณณ์— ๋ณด๊ด€ํ•˜์„ธ์š”!

Step 3: SDK ์„ค์น˜ & ์ฒซ ์—์ด์ „ํŠธ ๋งŒ๋“ค๊ธฐ

pip install ai-teammate
from ai_teammate import AITeammate

# API ํ‚ค๋กœ ํด๋ผ์ด์–ธํŠธ ์ดˆ๊ธฐํ™”
client = AITeammate(api_key="at_your_key_here")

# ์ฒซ ์—์ด์ „ํŠธ ๋งŒ๋“ค๊ธฐ
agent = client.agents.create(
    name="My First Agent",
    system_prompt="You are a helpful assistant that speaks Korean.",
)
print(f"โœ… ์—์ด์ „ํŠธ ์ƒ์„ฑ ์™„๋ฃŒ! ID: {agent.id}")

# ์—์ด์ „ํŠธ์™€ ๋Œ€ํ™”
response = client.chat("์•ˆ๋…•ํ•˜์„ธ์š”!", agent_id=agent.id)
print(f"๐Ÿค– {response.content}")

Step 4: ํฌํ„ธ์—์„œ ํ™•์ธ

SDK๋กœ ์ƒ์„ฑํ•œ ์—์ด์ „ํŠธ๋Š” ํฌํ„ธ ๋Œ€์‹œ๋ณด๋“œ์—์„œ ํ™•์ธํ•˜๊ณ  ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.


Quick Start

from ai_teammate import AITeammate

# Initialize client
client = AITeammate(api_key="at_your_api_key")

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

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.",
    model="claude-3-sonnet",
)

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

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

๐Ÿ’ฌ 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)

๐Ÿ‘ฅ 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.content)

# Chat with specific mode
response = client.teams.chat(
    team.id,
    "Should we use microservices?",
    mode="debate",  # Agents debate pros and cons
)

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

๐Ÿ”‘ Team API Keys

Generate API keys scoped to a team from Team Settings > API on the web portal.

# Use a team API key
client = AITeammate(api_key="at_your_team_key")

# Chat with the team
response = client.teams.chat("team_id", "Analyze this data")
print(response.content)

# List team agents
agents = client.teams.list_agents("team_id")

๐Ÿ”— Share Links

# Create a share link for your agent
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}")

# List share links
shares = client.shares.list("abc123")

# Delete a share link
client.shares.delete("abc123", share.id)

Full Flow: Create Agent โ†’ Share โ†’ Use

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. Use the share link (same client, same API key)
info = client.shares.get_info(share.share_code)
response = client.shares.chat(share.share_code, "Hello!")
print(response.content)

# 4. Upload a document (if allowed)
doc = client.shares.upload_document(share.share_code, "./faq.pdf")
print(f"Uploaded: {doc.filename} ({doc.chunk_count} chunks)")

๐Ÿง  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")

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
)

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, chat
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.1.tar.gz (12.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.1-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for ai_teammate-0.2.1.tar.gz
Algorithm Hash digest
SHA256 c5270bb194772d231e6eb13d9a5797ff5e8ad3aa84f03a45b32af85825f32aa9
MD5 1ef98b96e0738f05dafd67c3fb7d38b3
BLAKE2b-256 f6b983717c00a72b30f6a78029a8c922f281d20279b1a20405fdfa436d3e3673

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for ai_teammate-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0084030eb2e53b03a6cb0418c58b94cb12146d430187dad84f62f266c1cca231
MD5 ab25e4a4ca3177e3ec133a72b7c0ee2e
BLAKE2b-256 8d2bd2591318abb2f14245a698cd77cee1c77dab125a47c0e3841e63ffb6650a

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