Git Product home page Git Product logo

co2api's Introduction

Cohere2OpenAI

Used to convert the Cohere API to OpenAI compatible API. Easily use Cohere with any OpenAI compatible client.

Before Using

You need to have a Cohere API key, if you don't have one, you can apply for Trial Key. It is completely free at the moment and will not charge you any fees. You don't even need to bind your credit card.

Demo (Public Convert API)

This is the public API I provide. I cannot guarantee stability, but you can use them for free without any deployment.

# Host: c.uid.si
# Endpoint: /v1/chat/completions
# Method: POST
# Headers: Content-Type: application/json, Authorization
curl https://c.uid.si/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer xxxxxxx" \
  -d '{
    "model": "command-r-plus",
    "messages": [
      {
        "role": "system",
        "content": "翻译为中文!"
      },
      {
        "role": "user",
        "content": "Hello!"
      }
    ],
    "stream": true
  }'

Compatibility

Currently it is only compatible with the Command family of models, if you pass in any other model, the default will be to use Command R+. Supports streaming and non-streaming output.

Models

{
  "created": 1692901427,
  "id": "command-r",
  "object": "model",
  "owned_by": "system"
},
{
  "created": 1692901427,
  "id": "command-r-plus",
  "object": "model",
  "owned_by": "system"
},
{
  "created": 1692901427,
  "id": "command-light",
  "object": "model",
  "owned_by": "system"
},
{
  "created": 1692901427,
  "id": "command-light-nightly",
  "object": "model",
  "owned_by": "system"
},
{
  "created": 1692901427,
  "id": "command",
  "object": "model",
  "owned_by": "system"
},
{
  "created": 1692901427,
  "id": "command-nightly",
  "object": "model",
  "owned_by": "system"
}

Request Example

curl http://127.0.0.1:6600/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer xxxxxxx" \
  -d '{
    "model": "command-r-plus",
    "messages": [
      {
        "role": "system",
        "content": "翻译为中文!"
      },
      {
        "role": "user",
        "content": "Hello!"
      }
    ],
    "stream": true
  }'

Usage

Docker

docker run -d --restart always -p 6600:6600 ghcr.io/missuo/cohere2openai:latest
docker run -d --restart always -p 6600:6600 missuo/cohere2openai:latest

Docker Compose

It is recommended that you use docker version 26.0.0 or higher, otherwise you need to specify the version in the compose.yaml file.

+version: "3.9"
mkdir cohere2openai && cd cohere2openai
wget -O compose.yaml https://raw.githubusercontent.com/missuo/cohere2openai/main/compose.yaml
docker compose up -d

Manual

Download the latest release from the release page.

chmod +x cohere2openai
./cohere2openai

License

GPL 3.0

co2api's People

Contributors

missuo avatar fxcl avatar geekdada avatar imshire avatar beanqi avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.