cohere


Namecohere JSON
Version 5.3.3 PyPI version JSON
download
home_pageNone
SummaryNone
upload_time2024-04-23 13:37:00
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.
            # Cohere Python SDK

![](banner.png)

![version badge](https://img.shields.io/pypi/v/cohere)
![license badge](https://img.shields.io/github/license/cohere-ai/cohere-python)
[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-SDK%20generated%20by%20Fern-brightgreen)](https://github.com/fern-api/fern)

The Cohere Python SDK provides access to the Cohere API from Python.

## ✨🪩✨ Announcing Cohere's new Python SDK ✨🪩✨

We are very excited to publish this brand-new Python SDK. We will continuously update this library with all the latest features in our API. Please create issues where you have feedback so that we can continue to improve the developer experience!

## cohere==5.0.0 Migration Guide

We have created a [migration guide](4.0.0-5.0.0-migration-guide.md) to help you through the process. If you have any questions, please feel free to open an issue and we will respond to you asap.

## Documentation

Cohere documentation and API reference is available [here](https://docs.cohere.com/).

## Installation

```
pip install cohere
```

## Usage

```Python
import cohere

co = cohere.Client(
    api_key="YOUR_API_KEY",
)

chat = co.chat(
    message="hello world!",
    model="command"
)

print(chat)
```

> [!TIP]
> You can set a system environment variable `CO_API_KEY` to avoid writing your api key within your code, e.g. add `export CO_API_KEY=theapikeyforyouraccount`
> in your ~/.zshrc or ~/.bashrc, open a new terminal, then code calling `cohere.Client()` will read this key.


## Streaming

The SDK supports streaming endpoints. To take advantage of this feature for chat,
use `chat_stream`.

```Python
import cohere

co = cohere.Client(
    api_key="YOUR_API_KEY",
)

stream = co.chat_stream(
    message="Tell me a short story"
)

for event in stream:
    if event.event_type == "text-generation":
        print(event.text, end='')
```

## Contributing

While we value open-source contributions to this SDK, the code is generated programmatically. Additions made directly 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": "cohere",
    "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/49/87/78a38a664729a10a09873d01ff30a40afc4272b41de652cffcb2946c7195/cohere-5.3.3.tar.gz",
    "platform": null,
    "description": "# Cohere Python SDK\n\n![](banner.png)\n\n![version badge](https://img.shields.io/pypi/v/cohere)\n![license badge](https://img.shields.io/github/license/cohere-ai/cohere-python)\n[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-SDK%20generated%20by%20Fern-brightgreen)](https://github.com/fern-api/fern)\n\nThe Cohere Python SDK provides access to the Cohere API from Python.\n\n## \u2728\ud83e\udea9\u2728 Announcing Cohere's new Python SDK \u2728\ud83e\udea9\u2728\n\nWe are very excited to publish this brand-new Python SDK. We will continuously update this library with all the latest features in our API. Please create issues where you have feedback so that we can continue to improve the developer experience!\n\n## cohere==5.0.0 Migration Guide\n\nWe have created a [migration guide](4.0.0-5.0.0-migration-guide.md) to help you through the process. If you have any questions, please feel free to open an issue and we will respond to you asap.\n\n## Documentation\n\nCohere documentation and API reference is available [here](https://docs.cohere.com/).\n\n## Installation\n\n```\npip install cohere\n```\n\n## Usage\n\n```Python\nimport cohere\n\nco = cohere.Client(\n    api_key=\"YOUR_API_KEY\",\n)\n\nchat = co.chat(\n    message=\"hello world!\",\n    model=\"command\"\n)\n\nprint(chat)\n```\n\n> [!TIP]\n> You can set a system environment variable `CO_API_KEY` to avoid writing your api key within your code, e.g. add `export CO_API_KEY=theapikeyforyouraccount`\n> in your ~/.zshrc or ~/.bashrc, open a new terminal, then code calling `cohere.Client()` will read this key.\n\n\n## Streaming\n\nThe SDK supports streaming endpoints. To take advantage of this feature for chat,\nuse `chat_stream`.\n\n```Python\nimport cohere\n\nco = cohere.Client(\n    api_key=\"YOUR_API_KEY\",\n)\n\nstream = co.chat_stream(\n    message=\"Tell me a short story\"\n)\n\nfor event in stream:\n    if event.event_type == \"text-generation\":\n        print(event.text, end='')\n```\n\n## Contributing\n\nWhile we value open-source contributions to this SDK, the code is generated programmatically. Additions made directly 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!\n\nOn the other hand, contributions to the README are always very welcome!\n",
    "bugtrack_url": null,
    "license": null,
    "summary": null,
    "version": "5.3.3",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a0c39b74f01142cf0c7fddc865aa2bbe7b185370443cc327ea3cd6193cc09953",
                "md5": "86730a373b17d5bc5d0af45a1e3a6b7f",
                "sha256": "686db9d7c0b858be8c1da173fbe77dfda377fd794e221e473b654440e81336cd"
            },
            "downloads": -1,
            "filename": "cohere-5.3.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "86730a373b17d5bc5d0af45a1e3a6b7f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 151220,
            "upload_time": "2024-04-23T13:36:57",
            "upload_time_iso_8601": "2024-04-23T13:36:57.381577Z",
            "url": "https://files.pythonhosted.org/packages/a0/c3/9b74f01142cf0c7fddc865aa2bbe7b185370443cc327ea3cd6193cc09953/cohere-5.3.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "498778a38a664729a10a09873d01ff30a40afc4272b41de652cffcb2946c7195",
                "md5": "ef3362ee76e4bf928c88389b01974c10",
                "sha256": "fbf59c0bab0ded4d28091fa0c193a116d8303c4c0b09a42721dd8a1230ea27c3"
            },
            "downloads": -1,
            "filename": "cohere-5.3.3.tar.gz",
            "has_sig": false,
            "md5_digest": "ef3362ee76e4bf928c88389b01974c10",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 76031,
            "upload_time": "2024-04-23T13:37:00",
            "upload_time_iso_8601": "2024-04-23T13:37:00.049581Z",
            "url": "https://files.pythonhosted.org/packages/49/87/78a38a664729a10a09873d01ff30a40afc4272b41de652cffcb2946c7195/cohere-5.3.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-23 13:37:00",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "cohere"
}
        
Elapsed time: 0.25830s