> For the complete documentation index, see [llms.txt](https://docs.psynova.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.psynova.ai/psynova-sdk.md).

# PsyNova - SDK

<figure><img src="/files/gX78bqwtOuCpXmJ3eHW4" alt=""><figcaption></figcaption></figure>

{% embed url="<https://github.com/psynova-ai/psynova-sdk>" %}

***

## Technical Requirements

* Python 3.10 or higher
* Dependencies:
  * requests 2.31.0

***

## Quick Start

### Installation

<div align="left" data-full-width="false"><figure><img src="/files/SfsnUoTJpUokvQVNLo3D" alt="https://github.com/psynova-ai/psynova-sdk"><figcaption></figcaption></figure></div>

```
pip install psynova==1.2
```

***

### Basic Usage

```
from psynova import PsynovaClient

# Initialize the client
client = PsynovaClient(
    private_key="your_private_key",
    base_url="https://api.psynova.ai"  # Optional: defaults to dev environment
)

# Create a new agent
agent_id = client.create_agent(
    name="My AI Agent",
    version_id=1,
    using_https=True,
    using_socket=True
)

# Chat with the agent
response = client.chat(
    agent_id=agent_id,
    message="Hello, AI agent!"
)
print(response)
```

***

### Error Handling

The framework includes robust error handling through the `PsynovaAPIError` class, which provides detailed error messages and optional additional error context when API requests fail.

```
try:
    response = client.chat(agent_id=1, message="Hello")
except PsynovaAPIError as e:
    print(f"Error: {str(e)}")
    if e.errors:
        print(f"Additional details: {e.errors}")
```

***

### API Reference

#### PsynovaClient

**Constructor**

```
client = PsynovaClient(private_key, base_url="https://api.psynova.ai", timeout=30)
```

* `private_key` (str): Private key for authentication
* `base_url` (str, optional): Base URL for API. Defaults to development environment
* `timeout` (int, optional): Request timeout in seconds. Defaults to 30

**Methods**

> **get\_agent(agent\_id)**

Retrieves details of a specific agent.

```
agent = client.get_agent(agent_id=1)
```

Returns: Dictionary containing agent details (id, name, version\_id, status)

> **list\_agents()**

Lists all agents associated with the account.

```
agents = client.list_agents()
```

Returns: List of dictionaries containing agent details

> **chat(agent\_id, message)**

Sends a chat message to an agent.

```
response = client.chat(agent_id=1, message="Hello!")
```

Returns: String containing the agent's response

> **create\_agent(name, version\_id, using\_https=True, using\_socket=True)**

Creates a new agent with specified configuration.

```
agent_id = client.create_agent(
    name="My Agent",
    version_id=1,
    using_https=True,
    using_socket=True
)
```

Returns: Integer ID of the newly created agent


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.psynova.ai/psynova-sdk.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
