Skip to content

reAPIAI/reapi-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

reapi

OpenAI-compatible SDK for the reAPI gateway.

reAPI speaks the OpenAI API. This package is a thin wrapper around the official openai client, pre-pointed at https://api.reapi.ai/v1 — so you keep every method, type, and streaming helper you already know.

Install

pip install reapi-sdk

Quick start

from reapi_sdk import create_reapi

# Reads your key from REAPI_API_KEY, or pass api_key=...
client = create_reapi()

# Models are discovered at runtime — nothing is hard-coded:
models = client.models.list()

res = client.chat.completions.create(
    model=models.data[0].id,
    messages=[{"role": "user", "content": "Hello from reAPI"}],
)
print(res.choices[0].message.content)

Streaming

stream = client.chat.completions.create(
    model="<model-id>",
    messages=[{"role": "user", "content": "Stream this"}],
    stream=True,
)
for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="")

API key

Get an API key at reapi.ai. Provide it either way:

client = create_reapi(api_key="YOUR_KEY")
export REAPI_API_KEY=YOUR_KEY

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages