UniqueDeveloper docsGitHub ↗

Unique Interface

Give a Python function a browser UI. Share a link and let someone run it on your machine.

Run your first app

Install in a terminal, or use %pip install -U unique-interface in a notebook.

python -m pip install -U unique-interface

Python

from unique_interface import Interface

def greet(name):
    return f"Hello, {name}!"

app = Interface(greet, title="Greeting")
app.launch(share=True)

Choose inputs and outputs

Forms
Text, numbers, checkboxes, sliders, JSON, dropdowns, radio buttons, checkbox groups, colors and code. Pass a list for multiple inputs.
Media
Images, audio, video and files. Uploaded values expose name, mime, and data. Audio supports microphone recording in compatible browsers.
Tables
Use Dataframe(["City", "Sales"]) to add, edit and remove rows. Input cells arrive as text. Return rows with the same column count for a table output.
Charts
Return numbers for a line or bar plot, or (x, y) pairs for a scatter plot.
from unique_interface import Interface, Slider

def scale(value):
    return [value * n for n in range(6)]

Interface(scale, Slider(1, 10), "chart").launch()

Call the API & read response time

Open Use via API in a running function app to see its endpoints and send a test request. Use the Python client from another script:

from unique_interface import Client

client = Client(app_url)  # The address printed at launch
print(client.schema()["events"])
print(client.predict("Ada")["outputs"])

The same app serves a JavaScript client at /client.mjs.

The form shows the elapsed server time after a successful callback, including waiting for the app’s callback lock. The chat shows elapsed time until the reply completes. Browser model loading can affect the first answer.

curl "$APP_URL/api/predict" \
  -H 'Content-Type: application/json' \
  -d '{"inputs":["Ada"]}'

Set APP_URL to the printed local or public address. The JSON response contains outputs and duration_ms. Use GET /api/schema to inspect the app.

Chat, tabs and events

In version 0.1.6, combine existing function apps with TabbedInterface([a, b], ["First", "Second"]). Use Accordion for collapsible settings. Components inside Blocks support change, Enter-to-submit and file-upload callbacks. The outer function app accepts theme="dark", "light" or "auto".

from unique_interface import ChatInterface

def reply(message, history):
    return f"You wrote: {message}"

ChatInterface(reply).launch(share=True)

For a custom layout, use Blocks, Row, Column, and Tab. Connect a button to a Python callback with click.

from unique_interface import Blocks, Tab, Textbox, Button

with Blocks("Text tools") as app:
    with Tab("Uppercase"):
        source = Textbox("Your text")
        result = Textbox("Result")
        Button("Convert").click(str.upper, source, result,
                                api_name="uppercase")
app.launch()

Advanced runtime · development preview

Run the notebook to create a stateful counter, submit a background job, and display an inline chat.

Open advanced notebook in Colab Open advanced notebook in Jupyter Open advanced notebook in VS Code

Colab opens the hosted notebook. Jupyter launches Binder. VS Code opens the notebook editor; select a Python kernel to execute it.

Callbacks
Chain listeners with .then() or .success(). Add page-load callbacks and timers, or render a new view from Python.
Background work
The ASGI app exposes queue position, progress, polling and cancellation. A running Python callback cooperates by yielding or calling progress().
Media
Use a webcam, edit images, display figures, or send text and attachments in one chat message. WebRTC accepts an audio/video frame transform.
Integrations
Mount the app in FastAPI, expose MCP tools, bind local handlers to OpenAPI operations, or export a JSON-based function for browser-only execution with Pyodide.

Installation, examples, supported formats and deployment configuration

Deploy on Hugging Face

Run a model in the visitor’s browser

Choose Static and duplicate the working UniqueChat Space. Replace its model with a compatible Transformers.js ONNX chat model.

Open the reusable Static Space ↗

Run your own Python callback

Choose Docker if your account offers it. Copy the three starter files to the Space root, edit the Python function and choose public or private visibility.

Open the Docker starter ↗

Hugging Face manages the SDK picker. Unique Interface runs inside the selected hosting option.