cohere


Namecohere JSON
Version 5.5.7 PyPI version JSON
download
home_pageNone
SummaryNone
upload_time2024-06-11 13:29:11
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)](https://pypi.org/project/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 allows access to Cohere models across many different platforms: the cohere platform, AWS (Bedrock, Sagemaker), Azure, GCP and Oracle OCI. For a full list of support and snippets, please take a look at the [SDK support docs page](https://docs.cohere.com/docs/cohere-works-everywhere).

## 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/1c/43/c964746bbb0da5d4b9b0937dec174b5c570249c781a429a7cda7f000689a/cohere-5.5.7.tar.gz",
    "platform": null,
    "description": "# Cohere Python SDK\n\n![](banner.png)\n\n[![version badge](https://img.shields.io/pypi/v/cohere)](https://pypi.org/project/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 allows access to Cohere models across many different platforms: the cohere platform, AWS (Bedrock, Sagemaker), Azure, GCP and Oracle OCI. For a full list of support and snippets, please take a look at the [SDK support docs page](https://docs.cohere.com/docs/cohere-works-everywhere).\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.5.7",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0a2f8e9757765d8e7a37d8b83e56e5944011b4d335703d879f2c1c9488996415",
                "md5": "2454c662c99dc8ee4d12f271c1b3b1c1",
                "sha256": "fb8b6fa478b947fa12783e2bad8e4b748c1b2aa789ff3df7d1425288c98f45d8"
            },
            "downloads": -1,
            "filename": "cohere-5.5.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2454c662c99dc8ee4d12f271c1b3b1c1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 166550,
            "upload_time": "2024-06-11T13:29:08",
            "upload_time_iso_8601": "2024-06-11T13:29:08.665011Z",
            "url": "https://files.pythonhosted.org/packages/0a/2f/8e9757765d8e7a37d8b83e56e5944011b4d335703d879f2c1c9488996415/cohere-5.5.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1c43c964746bbb0da5d4b9b0937dec174b5c570249c781a429a7cda7f000689a",
                "md5": "f7f4f1b282917a7e7dc01b2ee6007b43",
                "sha256": "0801cfcfec4999c21cc2dc066436f4efb6c8d75bc94628247d8850064c6b7bcd"
            },
            "downloads": -1,
            "filename": "cohere-5.5.7.tar.gz",
            "has_sig": false,
            "md5_digest": "f7f4f1b282917a7e7dc01b2ee6007b43",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 80639,
            "upload_time": "2024-06-11T13:29:11",
            "upload_time_iso_8601": "2024-06-11T13:29:11.332707Z",
            "url": "https://files.pythonhosted.org/packages/1c/43/c964746bbb0da5d4b9b0937dec174b5c570249c781a429a7cda7f000689a/cohere-5.5.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-11 13:29:11",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "cohere"
}
        
Elapsed time: 0.25656s