Endpoints

The most important API endpoints developers will want to use.

/chat API Endpoint

The /chat endpoint is designed to handle chat requests, providing both streaming and non-streaming response options. It supports image content and ensures that the chat responses are processed efficiently. Before you can start using the API, you need to generate an API key.

Using the API Key

With your API key in hand, you can now make authenticated requests to the /chat endpoint. Below are examples of how to use the API for different scenarios.

Streaming Response Example

For a streaming response, where messages are sent and received in real-time, use the following Python code snippet:

import requests

url = "https://uiuc.chat/api/chat-api/chat"
headers = {
    'Content-Type': 'application/json',
}
data = {
    "model": "gpt-4o-mini",
    "messages": [
        {
            "role": "system",
            "content": "Your system prompt here"
        },
        {
            "role": "user",
            "content": "What is in these documents?"
        }
    ],
    "openai_key": "YOUR-OPENAI-KEY-HERE",
    "temperature": 0.1,
    "course_name": "your-course-name",
    "stream": True,
    "api_key": "YOUR_API_KEY"
}

response = requests.post(url, headers=headers, json=data)
print(response.text)

Non-Streaming Response Example

The non- streaming response will contain BOTH the LLM response and the relevant contexts

Retrieval Only

Note: This API response is free of cost provided by UIUC chat and will NOT invoke LLM and ONLY return relevant contexts

Image Input Example

To send an image as part of the conversation, include the image URL in the messages array:

Note: Image input is only allowed with gpt-4-vision-preview model for now

Multiple Messages in a Conversation

NCSA hosted models example

The best free option to use UIUC chat API is with LLAMA 3.1 70b model, hosted at NCSA.

Tool Use

Tools will be automatically invoked based on LLM's response. There's currently no way to force tool invocation, you will have to encourage the LLM to use tools via prompting.

For superior instruction following, GPT-4o model is always used for tool selection.

Note: Available tools can be viewed under settings on the chat page.

Coming soon

Document ingest via API. Currently only supported via the website GUI.

Last updated

Was this helpful?