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27
4.26.1
4.26
4.25
4.24
4.23
4.22
4.21
4.20.2
4.20.1
4.20.0
4.2.1
4.2.0
4.19.3
4.19.2
4.18.0
4.17.0
4.16.0
4.15.0
4.14.0
4.13.1
4.13.0
4.12.1
4.12.0
4.11.2
4.11.1
4.11.0
4.10.0
4.1.7
4.1.6
4.1.5
4.1.4
4.1.3
4.1.2
4.1.1
4.1.0
4.0.6
4.0.5
4.0.4
4.0.3
4.0.2
4.0.1
4.0.0
3.9.1
3.9.0
3.8.0
3.7.0
3.6.2
3.6.1
3.6.0
3.5.0
3.4.0
3.3.4
3.3.3
3.3.2
3.3.1
3.3.0
3.2.6
3.2.5
3.2.4
3.2.3
3.2.2
3.2.1
3.2.0
3.10.0
3.1.9
3.1.8
3.1.6
3.1.5
3.1.4
3.1.3
3.1.2
3.1.1
3.0.1
3.0.0
2.9.1
2.9.0
2.8.0
2.7.0
2.6.1
2.6.0
2.5.0
2.4.2
2.4.1
2.4.0
2.3.0
2.2.5
2.2.4
2.2.3
2.2.2
2.2.1
2.2.0
2.1.0
2.0.0
1.3.9
1.3.8
1.3.7
1.3.6
1.3.5
1.3.4
1.3.3
1.3.2
1.3.10
1.3.1
1.2.1
1.2.0
1.1.0
1.0.2
1.0.1
1.0.0
0.0.8
0.0.7
0.0.6
0.0.5
0.0.4
0.0.3
0.0.2
0.0.13
0.0.12
0.0.11
0.0.10
0.0.1
توضیحات
-
| ویژگی | مقدار |
|---|---|
| سیستم عامل | POSIX :: Linux |
| نام فایل | cohere-6.1.0 |
| نام | cohere |
| نسخه کتابخانه | 6.1.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | - |
| ایمیل نویسنده | - |
| آدرس صفحه اصلی | - |
| آدرس اینترنتی | https://pypi.org/project/cohere/ |
| مجوز | MIT |
# Cohere Python SDK

[](https://pypi.org/project/cohere/)

[](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.ClientV2()
response = co.chat(
model="command-r-plus-08-2024",
messages=[{"role": "user", "content": "hello world!"}],
)
print(response)
```
> [!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.ClientV2()
response = co.chat_stream(
model="command-r-plus-08-2024",
messages=[{"role": "user", "content": "hello world!"}],
)
for event in response:
if event.type == "content-delta":
print(event.delta.message.content.text, end="")
```
## Oracle Cloud Infrastructure (OCI)
The SDK supports Oracle Cloud Infrastructure (OCI) Generative AI service. First, install the OCI SDK:
```
pip install 'cohere[oci]'
```
Then use the `OciClient` or `OciClientV2`:
```Python
import cohere
# Using OCI config file authentication (default: ~/.oci/config)
co = cohere.OciClient(
oci_region="us-chicago-1",
oci_compartment_id="ocid1.compartment.oc1...",
)
response = co.embed(
model="embed-english-v3.0",
texts=["Hello world"],
input_type="search_document",
)
print(response.embeddings)
```
### OCI Authentication Methods
**1. Config File (Default)**
```Python
co = cohere.OciClient(
oci_region="us-chicago-1",
oci_compartment_id="ocid1.compartment.oc1...",
# Uses ~/.oci/config with DEFAULT profile
)
```
**2. Custom Profile**
```Python
co = cohere.OciClient(
oci_profile="MY_PROFILE",
oci_region="us-chicago-1",
oci_compartment_id="ocid1.compartment.oc1...",
)
```
**3. Session-based Authentication (Security Token)**
```Python
# Works with OCI CLI session tokens
co = cohere.OciClient(
oci_profile="MY_SESSION_PROFILE", # Profile with security_token_file
oci_region="us-chicago-1",
oci_compartment_id="ocid1.compartment.oc1...",
)
```
**4. Direct Credentials**
```Python
co = cohere.OciClient(
oci_user_id="ocid1.user.oc1...",
oci_fingerprint="xx:xx:xx:...",
oci_tenancy_id="ocid1.tenancy.oc1...",
oci_private_key_path="~/.oci/key.pem",
oci_region="us-chicago-1",
oci_compartment_id="ocid1.compartment.oc1...",
)
```
**5. Instance Principal (for OCI Compute instances)**
```Python
co = cohere.OciClient(
auth_type="instance_principal",
oci_region="us-chicago-1",
oci_compartment_id="ocid1.compartment.oc1...",
)
```
### Supported OCI APIs
The OCI client supports the following Cohere APIs:
- **Embed**: Full support for all embedding models
- **Chat**: Full support with both V1 (`OciClient`) and V2 (`OciClientV2`) APIs
- Streaming available via `chat_stream()`
- Supports Command-R and Command-A model families
### OCI Model Availability and Limitations
**Available on OCI On-Demand Inference:**
- ✅ **Embed models**: available on OCI Generative AI
- ✅ **Chat models**: available via `OciClient` (V1) and `OciClientV2` (V2)
**Not Available on OCI On-Demand Inference:**
- ❌ **Generate API**: OCI TEXT_GENERATION models are base models that require fine-tuning before deployment
- ❌ **Rerank API**: OCI TEXT_RERANK models are base models that require fine-tuning before deployment
- ❌ **Multiple Embedding Types**: OCI on-demand models only support single embedding type per request (cannot request both `float` and `int8` simultaneously)
**Note**: To use Generate or Rerank models on OCI, you need to:
1. Fine-tune the base model using OCI's fine-tuning service
2. Deploy the fine-tuned model to a dedicated endpoint
3. Update your code to use the deployed model endpoint
For the latest model availability, see the [OCI Generative AI documentation](https://docs.oracle.com/en-us/iaas/Content/generative-ai/home.htm).
## 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!
نیازمندی
| مقدار | نام |
|---|---|
| xtr | aiohttp<4,>=3.10.0; |
| - | fastavro<2.0.0,>=1.9.4 |
| - | httpx>=0.21.2 |
| xtr | httpx-aiohttp==0.1.8; |
| xtr | oci<3.0.0,>=2.165.0; |
| - | pydantic>=1.9.2 |
| - | pydantic-core<2.44.0,>=2.18.2 |
| - | requests<3.0.0,>=2.0.0 |
| - | tokenizers<1,>=0.15 |
| - | types-requests<3.0.0,>=2.0.0 |
| - | typing_extensions>=4.0.0 |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| <4.0,>=3.10 | Python |
نحوه نصب
نصب پکیج whl cohere-6.1.0:
pip install cohere-6.1.0.whl
نصب پکیج tar.gz cohere-6.1.0:
pip install cohere-6.1.0.tar.gz