Skip to main content

Unified Python SDK for multiple AI providers with automatic conversation management

Project description

BifrostAI Python SDK

Official Python SDK for BifrostAPI — one API for various AI models (ChatGPT, Claude, Gemini).

Get Your API Key

Subscribe to BifrostAPI on one of these platforms:

Installation

pip install bifrost-ai

Quick Start

from bifrost import BifrostAI

client = BifrostAI(
    api_key="bfr-xxxxx",
    openai_key="sk-xxxxx",
    storage="memory"
)

response = client.chat("conv1", "Hello!", model="gpt-4")
print(response.content)

Storage Options

The storage parameter is required when using methods with conversation_id (automatic history management).

Method Storage Required
client.chat() ✅ Yes
client.chat_with_files() ✅ Yes
client.chat_stream() ✅ Yes
client.create_chat_completion() ❌ No

Storage backends:

Type Format Persistence
Memory "memory" ❌ Lost on restart
File "file://path.json" ✅ Saved to disk
Redis "redis://localhost:6379" ✅ Saved to Redis
PostgreSQL "postgresql://user:pass@host/db" ✅ Saved to DB

High-level API (requires storage)

client = BifrostAI(api_key="...", openai_key="...", storage="memory")

# SDK manages conversation history automatically
response = client.chat("conv1", "My name is Farid", model="gpt-4")
response = client.chat("conv1", "What is my name?", model="gpt-4")  # Remembers!

Low-level API (no storage needed)

client = BifrostAI(api_key="...", openai_key="...")

# You manage messages yourself
response = client.create_chat_completion(
    model="gpt-4",
    messages=[{"role": "user", "content": "Hello"}]
)

Streaming

for chunk in client.chat_stream("conv1", "Count 1 to 5", model="gpt-4"):
    print(chunk.content, end="", flush=True)

File Upload

# Simple - just pass file paths
response = client.chat_with_files(
    "conv1",
    "Summarize this document",
    files=["document.pdf"],  # Same folder
    model="gpt-4-turbo"
)
print(response.content)

# Full path
response = client.chat_with_files(
    "conv1",
    "What is in this file?",
    files=[r"C:\Users\You\Documents\report.pdf"],
    model="gpt-4-turbo"
)

# Multiple files
response = client.chat_with_files(
    "conv1",
    "Compare these documents",
    files=["doc1.pdf", "doc2.pdf"],
    model="gpt-4-turbo"
)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bifrost_ai-1.0.0.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bifrost_ai-1.0.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file bifrost_ai-1.0.0.tar.gz.

File metadata

  • Download URL: bifrost_ai-1.0.0.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for bifrost_ai-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9240c6f28afc8a79b16c5ce1e591c6051db360c97a9a95b5628509d3c7ab38f5
MD5 7180bd1733971a219b9b5bb7df5adf8a
BLAKE2b-256 70cde64ceef7555e3fb6a405325b83461fb800fd1be4a875468f45ab8fbd14c5

See more details on using hashes here.

File details

Details for the file bifrost_ai-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: bifrost_ai-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for bifrost_ai-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c29eeb5275dd229ee0304a9d681de1b7294b1fa3060b74b2c92310ec07458597
MD5 b9102f526edd2e97d887374398dc2b1d
BLAKE2b-256 6f0bd88b199caf0b2da872bcdfac7e9a78588a395ecde578d35401b5b417910e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page