OwlChat OpenAi API

OwlChat (Open WebUI) REST API

OwlChat (Open WebUI) provides a robust, OpenAI-compatible REST API that allows researchers, faculty, and students across Florida Atlantic University to programmatically interact with advanced AI models. By exposing standardized endpoints, the platform enables seamless integration into custom Python scripts, automated data pipelines, and popular IDE coding assistants like VS Code and PyCharm. The service operates directly within FAU’s high-performance computing infrastructure, ensuring low-latency performance while maintaining strict data governance for academic research projects. Access to the API is secured through user-generated API keys, backend routing controls, and granular role-based access permissions. Users can leverage these capabilities to execute text completions, generate high-dimensional text embeddings, process audio synthesis, and incorporate custom generative AI directly into their applications.

Interactive API Documentation (Swagger)

Creating an API Key

  1. Log in to OwlChat (https://chat.hpc.fau.edu/).
  2. Click on your profile icon in the bottom-left or top-right corner.
  3. Select Account.
  4. Click Show next to the API Keys section, then click Create API Key.
  5. Creating an API Key in Account Settings

Connecting to an IDE

To connect OwlChat models to an IDE for use with coding assistants, use your API key and the base URL below:

  • Base URL: https://chat.hpc.fau.edu/api/v1
  • Refer to your specific IDE's documentation (e.g., VS Code, PyCharm, Continue) for exact configuration steps.

API Request Examples

1. List Available Models

Request:

#!/bin/bash

OPENAI_API_KEY="YOUR_API_TOKEN_FROM_SETTINGS"

curl -X 'GET' \
  'https://chat.hpc.fau.edu/openai/models' \
  -H 'accept: application/json' \
  -H "Authorization: Bearer $OPENAI_API_KEY" | jq

Response:

{
  "data": [
    {
      "id": "Llama-3.2-11B-Vision-Instruct",
      "object": "model",
      "created": 1677610602,
      "owned_by": "openai",
      "name": "Llama-3.2-11B-Vision-Instruct",
      "openai": {
        "id": "Llama-3.2-11B-Vision-Instruct",
        "object": "model",
        "created": 1677610602,
        "owned_by": "openai"
      },
      "urlIdx": 1
    },
    {
      "id": "Llama-3.2-3B-Instruct",
      "object": "model",
      "created": 1677610602,
      "owned_by": "openai",
      "name": "Llama-3.2-3B-Instruct",
      "openai": {
        "id": "Llama-3.2-3B-Instruct",
        "object": "model",
        "created": 1677610602,
        "owned_by": "openai"
      },
      "urlIdx": 1
    },
    {
      "id": "mistral-large",
      "object": "model",
      "created": 1677610602,
      "owned_by": "openai",
      "name": "mistral-large",
      "openai": {
        "id": "mistral-large",
        "object": "model",
        "created": 1677610602,
        "owned_by": "openai"
      },
      "urlIdx": 1
    }
  ]
}

2. Chat Completions

Request:

#!/bin/bash

OPENAI_API_KEY="YOUR_API_TOKEN_FROM_SETTINGS"

curl https://chat.hpc.fau.edu/openai/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "microsoft/phi-4",
    "messages": [
      {
        "role": "developer",
        "content": "You are a helpful assistant."
      },
      {
        "role": "user",
        "content": "Hello!"
      }
    ]
  }' | jq

Response:

{
  "id": "chatcmpl-a3328b366e3848699e0a353e23080987",
  "created": 1740508508,
  "model": "microsoft/phi-4",
  "object": "chat.completion",
  "system_fingerprint": null,
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "message": {
        "content": "Hello! How can I assist you today? Let me know if there's anything specific you'd like help with. 😊",
        "role": "assistant",
        "tool_calls": null,
        "function_call": null,
        "refusal": null,
        "reasoning_content": null
      }
    }
  ],
  "usage": {
    "completion_tokens": 26,
    "prompt_tokens": 19,
    "total_tokens": 45,
    "completion_tokens_details": null,
    "prompt_tokens_details": null
  },
  "service_tier": null,
  "prompt_logprobs": null
}

3. Text Embeddings

Request (Python):

import requests
from typing import Dict, Any

OWLCHAT_BASE_URL = "https://chat.hpc.fau.edu"
OWLCHAT_API_KEY = "YOUR_API_TOKEN_FROM_SETTINGS"

def owlchat_embedding(text: str = "test") -> list:
    """Returns embedding vector for provided text."""
    headers = {
        'accept': 'application/json',
        'Content-Type': 'application/json',
        'Authorization': f"Bearer {OWLCHAT_API_KEY}"
    }

    payload = {
        "model": "openai/nomic-embed-text:v1.5",
        "input": [text]
    }

    try:
        url = f"{OWLCHAT_BASE_URL}/api/v1/embeddings"
        response = requests.post(url, headers=headers, json=payload, timeout=120)
        response.raise_for_status()
        return response.json().get("data")[0].get('embedding')
    except Exception as e:
        raise Exception(f"API Error: {e}")

# Example invocation
owlchat_embedding("test")

Response:

[0.028818086, 0.011661014, -0.19171928, -0.008999387, 0.062924355, 0.0060845003, 0.047766145, -0.004068488, 0.037168097, ...]

4. Image Generation

Generates an image using a supported image generation model. Generated images are stored temporarily in OwlChat and retrieved via a secondary request.

Generate Image Request (Python):

import requests

OWLCHAT_BASE_URL = "https://chat.hpc.fau.edu"
OWLCHAT_API_KEY = "YOUR_API_TOKEN_FROM_SETTINGS"

def generate_image(prompt: str = "a cat") -> list:
    """Generates an image via OwlChat API."""
    headers = {
        'accept': 'application/json',
        'Content-Type': 'application/json',
        'Authorization': f"Bearer {OWLCHAT_API_KEY}"
    }

    payload = {
        "model": "Image-Generator",  # Custom image model
        "prompt": prompt,
        "size": "1024x1024",        # Supported resolution
        "n": 1,
    }

    try:
        url = f"{OWLCHAT_BASE_URL}/api/v1/images/generations"
        response = requests.post(url, headers=headers, json=payload, timeout=120)
        response.raise_for_status()
        return response.json()
    except Exception as e:
        raise Exception(f"API Error: {e}")

img_response = generate_image("a cat")

Response:

[{'id': '0fffb6ed-947b-408c-9ff6-e6f5feedb6ff', 'url': '/api/v1/files/0fffb6ed-947b-408c-9ff6-e6f5feedb6ff/content', 'name': 'generated-image.png', 'content_type': 'image/png'}]

Save Image Locally (Python):

def get_image(file_url_path: str, output_filename: str = "generated-image.png"): 
    """Downloads and saves image locally using returned relative path."""
    full_url = f"{OWLCHAT_BASE_URL}{file_url_path}" 
    headers = {"Authorization": f"Bearer {OWLCHAT_API_KEY}"} 
    
    response = requests.get(full_url, headers=headers, timeout=60) 
    response.raise_for_status() 
    
    with open(output_filename, "wb") as f: 
        f.write(response.content) 
    print(f"Image saved locally as {output_filename}")

# Pass relative 'url' path from generation response above
if img_response:
    get_image(file_url_path=img_response[0].get('url'))

5. Text-to-Speech (TTS)

Request:

#!/bin/bash

OPENAI_API_KEY="YOUR_API_TOKEN_FROM_SETTINGS"
OPENAPI_BASE_URL="https://chat.hpc.fau.edu/api"

curl $OPENAPI_BASE_URL/v1/audio/speech \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "tts-1",
    "input": "Today is a wonderful day to build something people love!",
    "voice": "alloy",
    "response_format": "mp3",
    "speed": 1.0
  }' \
  --output speech.mp3

REST API Parameter Reference

Name Type Description
prompt string or array The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays. Note that <|endoftext|> is the document separator seen during training.
best_of integer Generates candidate completions server-side and returns the best completion (highest log probability per token). Results cannot be streamed.

Note: Consumes token quota rapidly. Ensure reasonable max_tokens and stop settings.
echo boolean Echo back the prompt in addition to the completion.
frequency_penalty number Number between -2.0 and 2.0. Positive values penalize new tokens based on existing frequency in text so far, decreasing repetition.
logit_bias object Modify the likelihood of specified tokens appearing in the completion. Accepts a JSON object mapping token IDs to bias values from -100 to 100 (e.g., {"50256": -100} bans <|endoftext|>).
logprobs integer Include log probabilities on the most likely output tokens (up to 5).
max_tokens integer Maximum number of tokens generated in completion. Prompt length plus max_tokens cannot exceed model context length.
n integer How many completions to generate for each prompt.
presence_penalty number Number between -2.0 and 2.0. Positive values penalize new tokens based on prior presence, encouraging novel topics.
seed integer Enables best-effort deterministic sampling for reproducible requests across identical parameters.
stop string or array Up to 4 sequences where token generation halts. Returned text excludes the stop sequence.
stream boolean Streams back partial progress via server-sent events (SSE).
suffix string Suffix appended after text completion (supported on select models like gpt-3.5-turbo-instruct).
temperature number Sampling temperature between 0 and 2. Higher values increase randomness; lower values make responses more deterministic.
top_p number Nucleus sampling threshold based on cumulative probability mass.
user string Unique end-user identifier to assist with abuse monitoring and telemetry.