推理提供商文档

Cohere

Hugging Face's logo
加入 Hugging Face 社区

并获得增强的文档体验

开始使用

Cohere

所有支持的 Cohere 模型都可以在这里找到

Cohere 为您带来尖端的多语言模型、高级检索和为现代企业量身定制的 AI 工作区——所有这些都在一个安全可靠的平台中。

Cohere 是第一个直接在 Hub 上共享和提供其模型的模型创建者,作为推理提供商。

支持的任务

聊天补全 (LLM)

了解更多关于聊天补全 (LLM) 的信息,请点击这里

import os
from huggingface_hub import InferenceClient

client = InferenceClient(
    provider="cohere",
    api_key=os.environ["HF_TOKEN"],
)

completion = client.chat.completions.create(
    model="CohereLabs/c4ai-command-r-plus",
    messages=[
        {
            "role": "user",
            "content": "What is the capital of France?"
        }
    ],
)

print(completion.choices[0].message)

聊天补全 (VLM)

了解更多关于聊天补全 (VLM) 的信息,请点击这里

import os
from huggingface_hub import InferenceClient

client = InferenceClient(
    provider="cohere",
    api_key=os.environ["HF_TOKEN"],
)

completion = client.chat.completions.create(
    model="CohereLabs/command-a-vision-07-2025",
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "Describe this image in one sentence."
                },
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
                    }
                }
            ]
        }
    ],
)

print(completion.choices[0].message)
< > 在 GitHub 上更新