litellm-mirror/openai-proxy
2023-10-25 08:47:29 -07:00
..
tests fix(openai-proxy/utils.py): adding caching 2023-10-23 17:01:03 -07:00
.env.template (feat) proxy server add auth strategyto template 2023-10-24 10:58:40 -07:00
Dockerfile (fix) proxy server docker file 2023-10-21 16:24:35 -07:00
main.py build(openai-proxy/main.py): adding embedding endpoint 2023-10-24 17:44:40 -07:00
openapi.json (feat) proxy add openapi.json 2023-10-25 08:47:29 -07:00
README.md Update README.md 2023-10-24 12:59:53 -07:00
requirements.txt docs(openai-proxy-readme): add docker package to readme 2023-10-23 17:24:16 -07:00
utils.py fix(openai-proxy/utils.py): remove print statements 2023-10-23 20:00:02 -07:00

openai-proxy

A simple, fast, and lightweight OpenAI-compatible server to call 100+ LLM APIs.

Usage

docker run -e PORT=8000 -p 8000:8000 ghcr.io/berriai/litellm:latest

# UVICORN: OpenAI Proxy running on http://0.0.0.0:8000

Endpoints:

  • /chat/completions - chat completions endpoint to call 100+ LLMs
  • /models - available models on server

Making Requests to Proxy

Curl

curl http://0.0.0.0:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
     "model": "gpt-3.5-turbo",
     "messages": [{"role": "user", "content": "Say this is a test!"}],
     "temperature": 0.7
   }'

Replace openai base

import openai 
openai.api_base = "http://0.0.0.0:8000"

# cohere call
response = openai.ChatCompletion.create(
        model="command-nightly",
        messages=[{"role":"user", "content":"Say this is a test!"}],
        api_key = "your-cohere-api-key"
)

# bedrock call
response = openai.ChatCompletion.create(
        model = "bedrock/anthropic.claude-instant-v1",
        messages=[{"role":"user", "content":"Say this is a test!"}],
        aws_access_key_id="",
        aws_secret_access_key="",
        aws_region_name="us-west-2",
)

print(response)

Running Locally

$ git clone https://github.com/BerriAI/litellm.git
$ cd ./litellm/openai-proxy
$ uvicorn main:app --host 0.0.0.0 --port 8000

See how to call Huggingface,Bedrock,TogetherAI,Anthropic, etc.