Skip to main content

talkit_agent

Talkit Agent turns any OpenAPI spec into a conversational API assistant. It understands user prompts, picks the right endpoint, makes the call, and returns the result. Just talk to your API.

Installation

You can install the talkit_agent package using pip:

pip install talkit-agent

Or clone the repository and install locally:

git clone https://github.com/your-username/talkit_agent.git
cd talkit_agent
pip install -e .

Requirements

  • Python 3.12 or later
  • OpenAI API key

Usage

import asyncio
import os
from talkit_agent import TalkitAgent
from talkit_agent.ai_models import AIModelClient
from talkit_agent.open_api import OpenAPIClient

# Define your OpenAPI spec
spec = {
    "openapi": "3.0.0",
    "info": {
        "title": "Example API",
        "version": "1.0.0",
    },
    "paths": {
        "/api/users": {
            "get": {
                "summary": "Get all users",
                "description": "Returns a list of all users in the system",
                "operationId": "getUsers",
                "responses": {
                    "200": {
                        "description": "Successful operation",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "array",
                                    "items": {
                                        "type": "object",
                                        "properties": {
                                            "id": {"type": "integer"},
                                            "name": {"type": "string"},
                                            "email": {"type": "string"},
                                        },
                                    },
                                }
                            }
                        },
                    }
                },
            }
        }
    },
}

async def main():
    # Initialize the TalkitAgent
    talkit_agent = TalkitAgent(
        base_url="https://api.example.com",
        headers={"Authorization": "Bearer YOUR_API_KEY"},
        open_api_client=OpenAPIClient(spec),
        ai_model_client=AIModelClient(api_key=os.getenv("OPENAI_API_KEY")),
    )

    # Create a new chat
    chat_id = talkit_agent.create_chat()

    # Send a message to the chat
    chat_message = await talkit_agent.send_message(
        chat_id=chat_id, prompt="List all users"
    )
    print(f"Chat ID: {chat_id} - Message: {chat_message.content}")

if __name__ == "__main__":
    asyncio.run(main())

API Reference

TalkitAgent

The main class that manages conversations and interactions with APIs.

  • __init__(base_url, headers, open_api_client, ai_model_client): Initialize the agent
  • create_chat(): Create a new chat session and return its ID
  • get_chat(chat_id): Get a chat by ID
  • list_chats(): List all available chat IDs
  • delete_chat(chat_id): Delete a chat by ID
  • send_message(chat_id, prompt): Send a message to a chat and get AI response

OpenAPIClient

Handles OpenAPI specification parsing and operation management.

  • __init__(spec): Initialize with an OpenAPI spec dictionary
  • from_string(data): Create from a JSON string
  • from_file(path): Create from a JSON file
  • list_operations(): List all available API operations
  • get_operation_details(path, method): Get details of an operation
  • get_operation_details_by_id(operation_id): Get operation details by ID

AIModelClient

Manages interactions with OpenAI models.

  • __init__(api_key=None, model=None): Initialize with an API key and model name
  • call(input, tools=None, output_format=None): Call the OpenAI API

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for talkit-agent 0.1.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 talkit-agent 0.1.3
File Size Uploaded Provenance Actions
talkit_agent-0.1.3.tar.gz 9.2 kB Without provenance Details for talkit_agent-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for talkit-agent 0.1.3
File Interpreter ABI Platform Actions
talkit_agent-0.1.3-py3-none-any.whl Python 3 none any Details for talkit_agent-0.1.3-py3-none-any.whl

Total release size: 19.3 kB

Release files / talkit_agent-0.1.3.tar.gz

Download URL talkit_agent-0.1.3.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
52f6c6af9a1d2fec00590be708fc35eae0af7bc0750ef48fcb626d92feff12aa
BLAKE2b-256 checksum
How to use checksums
a3e2a0586a70e9f614d3ff5b4b61501d84abbcec8f7064363cf5b5870a23d242
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.20

Release files / talkit_agent-0.1.3-py3-none-any.whl

Download URL talkit_agent-0.1.3-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
60bb28810b4074578219aa77177b874940d49057ff2d4548a1e0945fcc42e30a
BLAKE2b-256 checksum
How to use checksums
75a7522d4bf73365a162c908614bd98e918ea7166395b8d23b5fc5588284e090
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.20

Security for talkit-agent 0.1.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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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