Skip to content

API Usage

Note: This chapter is technical and intended for developers and technically proficient staff who want to integrate AI functionality directly into their own applications, scripts, or workflows.

The Open WebUI API opens comprehensive programmatic access to AI functionality, enabling automation, integration, and advanced workflow implementation while maintaining security and compliance standards.

Why Use the API?

While the web interface is ideal for interactive work, the API enables automation:

  • Batch Processing: Analyze or summarize hundreds of documents in automated scripts
  • Integration: Build AI functionality into existing software (e.g., laboratory information systems, custom web applications)
  • Service Development: Create your own chatbot or service that leverages the central infrastructure

Note on Fair Use: The API is designed for typical daily work and research volume. If you plan large-scale automated projects (e.g., processing entire research datasets with thousands of API calls), please contact your system administrators for resource planning.

Getting Started

Step 1: Generate Personal API Key

Every API request must be authenticated:

  1. Navigate to Settings (gear icon) in Open WebUI
  2. Select the Account tab
  3. Click "Create API Key"
  4. Copy the displayed key and store it securely (e.g., in a password manager)

Security Warning: Treat your API key like a password! Never share it with others or write it in publicly accessible code.

Step 2: API Endpoints and Documentation

The central API resource is the interactive documentation where you can test requests directly in your browser:

  • Interactive API Documentation (Swagger UI): https://openwebui.scc.kit.edu/docs

Key endpoints: - Base URL: https://openwebui.scc.kit.edu/v1 - Chat Completions Endpoint: https://openwebui.scc.kit.edu/v1/chat/completions

Step 3: Making API Requests

cURL Example (in Terminal):

# Replace YOUR_PERSONAL_API_KEY with your copied key
curl -X POST https://openwebui.scc.kit.edu/v1/chat/completions \
-H "Authorization: Bearer YOUR_PERSONAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "model": "C-Chat-OpenAI.Azure-gpt-4.1-mini-stable",
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful assistant."
    },
    {
      "role": "user", 
      "content": "Explain the principle of Rayleigh scattering in three sentences."
    }
  ]
}'

Python Example (with openai library):

# First install: pip install openai
from openai import OpenAI

# Configure API key and endpoint
api_key = "YOUR_PERSONAL_API_KEY"
base_url = "https://openwebui.scc.kit.edu/v1"

# Initialize client
client = OpenAI(api_key=api_key, base_url=base_url)

try:
    # Send chat request
    chat_completion = client.chat.completions.create(
        model="C-Chat-OpenAI.Azure-gpt-4.1-mini-stable",
        messages=[
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": "Explain the principle of Rayleigh scattering in three sentences."}
        ]
    )
    # Output response
    print(chat_completion.choices.message.content)
except Exception as e:
    print(f"An error occurred: {e}")

OpenAI Compatibility

Our API uses the established OpenAI standard, meaning almost all existing libraries, code examples, and tutorials for OpenAI's Chat Completions API work with minimal adjustments.

Advanced: Knowledge Store Management (RAG)

With Retrieval-Augmented Generation (RAG), you can provide documents as context for AI responses. While uploading individual documents is convenient through the web interface, the API is the method for automation and bulk document uploads.

RAG API Endpoints

The specific endpoints for managing files and knowledge stores (creation, upload, deletion, etc.) are available in the interactive API documentation at https://openwebui.scc.kit.edu/docs.

Important: Data Preparation for Best Results

To achieve the best results with RAG, the quality of your source documents is crucial:

Best Practice: Prepare your source documents in clean, structured Markdown format before uploading. Headings, lists, and tables in Markdown format help the model reliably interpret structure and context. Tools like Docling can be helpful for converting various formats to Markdown.

Common Applications

Automation and Scripting

  • Document Processing: Systematic analysis of large document collections
  • Report Generation: Automated creation of standardized outputs
  • Content Analysis: Systematic review processes
  • Data Processing: Structured extraction from unstructured information

System Integration

  • Internal Applications: Connect AI capabilities to existing software
  • Workflow Automation: Accelerate business processes, reduce manual intervention

Advanced Use Cases

  • Chatbots: Conversational access to organizational knowledge
  • Content Management: Automated document workflows
  • Research Applications: Data interpretation, pattern recognition, investigation assistance

Error Handling

Common error types and solutions:

  • Authentication Errors: Invalid or expired API keys
  • Rate Limiting: System overload prevention
  • Model Specification Errors: Referencing non-existent models
  • Content Policy Violations: Attempting restricted content

Best Practices

  • Secure Key Management: Use environment variables, avoid hardcoding keys
  • Comprehensive Error Handling: Protect both application and platform
  • Input Validation: Ensure data integrity
  • Request Logging: Support debugging and performance optimization
  • Secure Connections: Use HTTPS and validate permissions
  • Performance Optimization: Caching, appropriate request sizing, graceful timeouts

Rate Limits and Performance

The system is designed to support typical organizational usage patterns with appropriate resource allocation. Fair-use policies ensure performance for all users.

Support Resources

  • Interactive API Explorer: Test endpoints directly
  • Documentation: Comprehensive endpoint specifications
  • Technical Support: Available through institutional channels

The API extends Open WebUI's functionality beyond the web interface, enabling custom applications, automated workflows, and sophisticated integrations while maintaining robust security, compliance, and technical standards.