letta-client


Nameletta-client JSON
Version 0.1.231 PyPI version JSON
download
home_pageNone
SummaryNone
upload_time2025-07-30 05:39:57
maintainerNone
docs_urlNone
authorNone
requires_python<4.0,>=3.8
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Letta Python Library

[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Fletta-ai%2Fletta-python)
[![pypi](https://img.shields.io/pypi/v/letta-client)](https://pypi.python.org/pypi/letta-client)

The Letta Python library provides convenient access to the Letta API from Python.

## Installation

```sh
pip install letta-client
```

## Reference

A full reference for this library is available [here](https://github.com/letta-ai/letta-python/blob/HEAD/./reference.md).

## Usage

Instantiate and use the client with the following:

```python
from letta_client import Letta

client = Letta(
    project="YOUR_PROJECT",
    token="YOUR_TOKEN",
)
client.tools.create(
    source_code="source_code",
)
```

## Async Client

The SDK also exports an `async` client so that you can make non-blocking calls to our API.

```python
import asyncio

from letta_client import AsyncLetta

client = AsyncLetta(
    project="YOUR_PROJECT",
    token="YOUR_TOKEN",
)


async def main() -> None:
    await client.tools.create(
        source_code="source_code",
    )


asyncio.run(main())
```

## Exception Handling

When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
will be thrown.

```python
from letta_client.core.api_error import ApiError

try:
    client.tools.create(...)
except ApiError as e:
    print(e.status_code)
    print(e.body)
```

## Streaming

The SDK supports streaming responses, as well, the response will be a generator that you can loop over.

```python
from letta_client import Letta, StdioServerConfig

client = Letta(
    project="YOUR_PROJECT",
    token="YOUR_TOKEN",
)
response = client.tools.connect_mcp_server(
    request=StdioServerConfig(
        server_name="server_name",
        command="command",
        args=["args"],
    ),
)
for chunk in response:
    yield chunk
```

## Advanced

### Retries

The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
retry limit (default: 2).

A request is deemed retryable when any of the following HTTP status codes is returned:

- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)

Use the `max_retries` request option to configure this behavior.

```python
client.tools.create(..., request_options={
    "max_retries": 1
})
```

### Timeouts

The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.

```python

from letta_client import Letta

client = Letta(
    ...,
    timeout=20.0,
)


# Override timeout for a specific method
client.tools.create(..., request_options={
    "timeout_in_seconds": 1
})
```

### Custom Client

You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
and transports.
```python
import httpx
from letta_client import Letta

client = Letta(
    ...,
    httpx_client=httpx.Client(
        proxies="http://my.test.proxy.example.com",
        transport=httpx.HTTPTransport(local_address="0.0.0.0"),
    ),
)
```

## Contributing

While we value open-source contributions to this SDK, this library is generated programmatically.
Additions made directly to this library would have to be moved over to our generation code,
otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
an issue first to discuss with us!

On the other hand, contributions to the README are always very welcome!

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "letta-client",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/45/d3/59c408c195e0a15debb80490a9ed8f64b85bc8ec5da2994c0821a92c4823/letta_client-0.1.231.tar.gz",
    "platform": null,
    "description": "# Letta Python Library\n\n[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Fletta-ai%2Fletta-python)\n[![pypi](https://img.shields.io/pypi/v/letta-client)](https://pypi.python.org/pypi/letta-client)\n\nThe Letta Python library provides convenient access to the Letta API from Python.\n\n## Installation\n\n```sh\npip install letta-client\n```\n\n## Reference\n\nA full reference for this library is available [here](https://github.com/letta-ai/letta-python/blob/HEAD/./reference.md).\n\n## Usage\n\nInstantiate and use the client with the following:\n\n```python\nfrom letta_client import Letta\n\nclient = Letta(\n    project=\"YOUR_PROJECT\",\n    token=\"YOUR_TOKEN\",\n)\nclient.tools.create(\n    source_code=\"source_code\",\n)\n```\n\n## Async Client\n\nThe SDK also exports an `async` client so that you can make non-blocking calls to our API.\n\n```python\nimport asyncio\n\nfrom letta_client import AsyncLetta\n\nclient = AsyncLetta(\n    project=\"YOUR_PROJECT\",\n    token=\"YOUR_TOKEN\",\n)\n\n\nasync def main() -> None:\n    await client.tools.create(\n        source_code=\"source_code\",\n    )\n\n\nasyncio.run(main())\n```\n\n## Exception Handling\n\nWhen the API returns a non-success status code (4xx or 5xx response), a subclass of the following error\nwill be thrown.\n\n```python\nfrom letta_client.core.api_error import ApiError\n\ntry:\n    client.tools.create(...)\nexcept ApiError as e:\n    print(e.status_code)\n    print(e.body)\n```\n\n## Streaming\n\nThe SDK supports streaming responses, as well, the response will be a generator that you can loop over.\n\n```python\nfrom letta_client import Letta, StdioServerConfig\n\nclient = Letta(\n    project=\"YOUR_PROJECT\",\n    token=\"YOUR_TOKEN\",\n)\nresponse = client.tools.connect_mcp_server(\n    request=StdioServerConfig(\n        server_name=\"server_name\",\n        command=\"command\",\n        args=[\"args\"],\n    ),\n)\nfor chunk in response:\n    yield chunk\n```\n\n## Advanced\n\n### Retries\n\nThe SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long\nas the request is deemed retryable and the number of retry attempts has not grown larger than the configured\nretry limit (default: 2).\n\nA request is deemed retryable when any of the following HTTP status codes is returned:\n\n- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)\n- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)\n- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)\n\nUse the `max_retries` request option to configure this behavior.\n\n```python\nclient.tools.create(..., request_options={\n    \"max_retries\": 1\n})\n```\n\n### Timeouts\n\nThe SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.\n\n```python\n\nfrom letta_client import Letta\n\nclient = Letta(\n    ...,\n    timeout=20.0,\n)\n\n\n# Override timeout for a specific method\nclient.tools.create(..., request_options={\n    \"timeout_in_seconds\": 1\n})\n```\n\n### Custom Client\n\nYou can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies\nand transports.\n```python\nimport httpx\nfrom letta_client import Letta\n\nclient = Letta(\n    ...,\n    httpx_client=httpx.Client(\n        proxies=\"http://my.test.proxy.example.com\",\n        transport=httpx.HTTPTransport(local_address=\"0.0.0.0\"),\n    ),\n)\n```\n\n## Contributing\n\nWhile we value open-source contributions to this SDK, this library is generated programmatically.\nAdditions made directly to this library would have to be moved over to our generation code,\notherwise they would be overwritten upon the next generated release. Feel free to open a PR as\na proof of concept, but know that we will not be able to merge it as-is. We suggest opening\nan issue first to discuss with us!\n\nOn the other hand, contributions to the README are always very welcome!\n",
    "bugtrack_url": null,
    "license": null,
    "summary": null,
    "version": "0.1.231",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "63cd7c006ba4f0446fc5ffeb69c33b30c2ed17b85b465bdc4de4e24e0ffe4d7d",
                "md5": "203f542a29c46ecd6cfb6357875d1c85",
                "sha256": "5e3a7104e310df6ca66d0e968c8f69edce02bcad5b155f2be7f35b8ef7799240"
            },
            "downloads": -1,
            "filename": "letta_client-0.1.231-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "203f542a29c46ecd6cfb6357875d1c85",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 335544,
            "upload_time": "2025-07-30T05:39:55",
            "upload_time_iso_8601": "2025-07-30T05:39:55.420419Z",
            "url": "https://files.pythonhosted.org/packages/63/cd/7c006ba4f0446fc5ffeb69c33b30c2ed17b85b465bdc4de4e24e0ffe4d7d/letta_client-0.1.231-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "45d359c408c195e0a15debb80490a9ed8f64b85bc8ec5da2994c0821a92c4823",
                "md5": "70044ffb48068cfcc1b2ba57efb1df8f",
                "sha256": "1ef4f50e736d1a027f9edb090f3ae3c89f48455cf5ec072a963f1808bd74bcf4"
            },
            "downloads": -1,
            "filename": "letta_client-0.1.231.tar.gz",
            "has_sig": false,
            "md5_digest": "70044ffb48068cfcc1b2ba57efb1df8f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 128198,
            "upload_time": "2025-07-30T05:39:57",
            "upload_time_iso_8601": "2025-07-30T05:39:57.272769Z",
            "url": "https://files.pythonhosted.org/packages/45/d3/59c408c195e0a15debb80490a9ed8f64b85bc8ec5da2994c0821a92c4823/letta_client-0.1.231.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-30 05:39:57",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "letta-client"
}
        
Elapsed time: 1.11023s