xai-gradio
is a Python package that makes it very easy for developers to create machine learning apps that are powered by XAI API.
Installation
You can install xai-gradio directly using pip:
pip install xai-gradio
That's it!
Basic Usage
You'll need to save your xAI API key to the appropriate environment variable:
export XAI_API_KEY=<your token>
Then in a Python file, write:
import gradio as gr
import xai_gradio
gr.load(
name='grok-beta',
src=xai_gradio.registry,
).launch()
Run the Python file, and you should see a Gradio Interface connected to your chosen model!
Customization
Once you can create a Gradio UI from an OpenAI endpoint, you can customize it by setting your own input and output components, or any other arguments to gr.Interface. For example, the screenshot below was generated with:
import gradio as gr
import xai_gradio
gr.load(
name='grok-beta',
src=xai_gradio.registry,
title='X.AI-Gradio Integration',
description="Chat with grok-beta model.",
examples=["Explain quantum gravity to a 5-year old.", "How many R are there in the word Strawberry?"]
).launch()
Composition
Or use your loaded Interface within larger Gradio Web UIs, e.g.
import gradio as gr
import xai_gradio
with gr.Blocks() as demo:
with gr.Tab("grok-beta"):
gr.load('grok-beta', src=xai_gradio.registry)
demo.launch()
Under the Hood
The xai-gradio Python library has two dependencies: openai and gradio. It defines a "registry" function xai_gradio.registry, which takes in a model name and returns a Gradio app.
Supported Models and Providers
The following AI models are currently supported:
- xAI (Grok-beta)
For a comprehensive list of available models and their specifications, please refer to:
Note: if you are getting authentication errors, ensure you have set the correct environment variable. You can also set it in your Python session:
import os
os.environ["XAI_API_KEY"] = ...
Metadata
Release files for xai-gradio 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| xai_gradio-0.0.2.tar.gz | 309.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| xai_gradio-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 313.0 kB
Release files / xai_gradio-0.0.2.tar.gz
| Download URL | xai_gradio-0.0.2.tar.gz |
|---|---|
| Size | 309.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c472da98a0d909c78d845af1447138ab39bf06a0501ee825c64409420f341f84
|
|
BLAKE2b-256 checksum How to use checksums |
97ce057df4fc475aaf460e3ff92e212fba7b6bfb33fa1ee9223f5177b3ae0af8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.6
|
Release files / xai_gradio-0.0.2-py3-none-any.whl
| Download URL | xai_gradio-0.0.2-py3-none-any.whl |
|---|---|
| Size | 3.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7f013545a0e852fd200dec43e4c57220aec5a5c21d6910159d71eaafcc5fca5b
|
|
BLAKE2b-256 checksum How to use checksums |
6252a76738332270c41f93d64603627c895bfb0e91a79da156ca88ad6e825901
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.6
|
Security for xai-gradio 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.