Skip to main content

A client library for the OpenWebUI API, compatible with OpenAI Python SDK

Project description

OpenWebUI Client

PyPI version Python versions Documentation License: MIT

A client library for the OpenWebUI API, compatible with the OpenAI Python SDK but with extensions specific to OpenWebUI features.

Installation

pip install openwebui-client

Quick Start

from openwebui_client import OpenWebUIClient

# Initialize client
client = OpenWebUIClient(
    api_key="your_api_key",  # Optional if set in environment variable
    base_url="http://your-openwebui-instance:5000",
    default_model="gpt-4"
)

# Basic chat completion
response = client.chat.completions.create(
    model="gpt-4",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Hello, world!"}
    ]
)
print(response.choices[0].message.content)

# Upload a file to OpenWebUI
with open("document.pdf", "rb") as file:
    uploaded_file = client.files.upload(file=file, purpose="assistant")

# Use file with chat completion
response = client.chat.completions.create(
    model="gpt-4",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Summarize this document for me."}
    ],
    file_ids=[uploaded_file.id]
)

Features

  • OpenAI Compatibility: Use the familiar OpenAI Python SDK interfaces
  • File Upload: Upload and process files with OpenWebUI
  • File-Aware Chat Completions: Reference files in chat completions
  • Typed Interface: Full type hints for better IDE integration

Documentation

Full documentation is available at https://bemade.github.io/openwebui-client/

Development

# Install development dependencies
pip install -e ".[dev]"

# Run tests
python -m pytest

# Build documentation
cd docs
make html

License

This project is licensed under the MIT License - see the LICENSE file for details.

Related Projects

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

openwebui_client-0.1.2.tar.gz (585.3 kB view details)

Uploaded Source

Built Distribution

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

openwebui_client-0.1.2-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file openwebui_client-0.1.2.tar.gz.

File metadata

  • Download URL: openwebui_client-0.1.2.tar.gz
  • Upload date:
  • Size: 585.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for openwebui_client-0.1.2.tar.gz
Algorithm Hash digest
SHA256 1d13e099e0b5d98b86ef38ab374555f6ca9196c4abd5063806b3c5e2aaa4a0cc
MD5 0354134c4186743f9c27cc94ce8d42f0
BLAKE2b-256 e1019f3684b798068c57500533cf04cbf5aa011a6c4961d7a0fb2e8fffdc4352

See more details on using hashes here.

File details

Details for the file openwebui_client-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for openwebui_client-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 44c150505a723d6d3c469ff70eae849b1717ddbcd21e5c0412aaa5c1833133a9
MD5 a9ccd25a03d75b4f64dcdf795bb91ccf
BLAKE2b-256 259a17461e2d3c682da13c171ec2e59628b638394f17b0cd9621d3ad84158e46

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