Skip to main content

JibayAI Python SDK

A small, validated Python client for the JibayAI chat, image, music and video APIs.

Installation

pip install jibayai

Quick start

from jibayai import JibayAI

client = JibayAI(api_key="YOUR_API_KEY")

result = client.chat(
    "Hello, how are you?",
    model="jibay-5",
)
print(result)

You may keep the key outside source code:

export JIBAYAI_API_KEY="YOUR_API_KEY"
from jibayai import JibayAI

client = JibayAI()
print(client.chat("سلام"))

Direct functions

For small scripts, the four operations are also available directly on the package:

import jibayai

result = jibayai.chat(
    "Hello",
    api_key="YOUR_API_KEY",
    model="jibay-5",
)

image_result = jibayai.image("A futuristic city", api_key="YOUR_API_KEY")
music_result = jibayai.music("Calm jazz", api_key="YOUR_API_KEY")
video_result = jibayai.video("Autumn forest", api_key="YOUR_API_KEY")

For repeated calls, prefer one JibayAI client so its HTTP connection is reused.

Chat

result = client.chat(
    text="Latest AI news",
    model="jibay-5",
    system="Answer clearly and briefly.",
    chats=[
        {"role": "user", "text": "My name is Ali"},
        {"role": "assistant", "text": "Nice to meet you"},
    ],
    search_web=True,
    signal=False,
    saved_memories={"language": "fa"},
    mode_official=False,
)

The documented chat request uses JSON. To support the previous form-encoded integration:

client = JibayAI(api_key="YOUR_API_KEY", chat_encoding="form")
# Or only for one request:
result = client.chat("Hello", encoding="form")

Image

The API requires a numeric device. The SDK generates one automatically when omitted.

result = client.image("A futuristic city at night")
# Or:
result = client.image("A futuristic city at night", device=12345)
print(result)

Music

result = client.music("Calm Persian jazz")
print(result)

Video

result = client.video("An autumn forest with cinematic camera movement")
print(result)

Download generated media

Generated media links are temporary, so save the result promptly:

saved_path = client.download(
    "https://example.com/temporary-file.mp4",
    "outputs/video.mp4",
)
print(saved_path)

Validation

The SDK validates API key, text, booleans, chat history, device ID, timeout, retry count, URLs and model identifier syntax before sending a request.

By default, new model names are allowed when their syntax is valid. Enable strict model validation when you need an allow-list:

client = JibayAI(
    api_key="YOUR_API_KEY",
    strict_models=True,
    supported_models=["jibay-4", "jibay-4.1", "jibay-5"],
)

Error handling

from jibayai import (
    JibayAI,
    JibayError,
    ValidationError,
    AuthenticationError,
    RateLimitError,
    TimeoutError,
    NetworkError,
    ServerError,
)

client = JibayAI(api_key="YOUR_API_KEY")

try:
    result = client.chat("Hello", model="jibay-5")
except ValidationError as exc:
    print("Bad parameter:", exc.parameter, exc)
except AuthenticationError:
    print("Check the API key")
except RateLimitError as exc:
    print("Rate limited; retry after:", exc.retry_after)
except TimeoutError:
    print("Request timed out")
except NetworkError:
    print("Network connection failed")
except ServerError as exc:
    print("JibayAI server error:", exc.status_code)
except JibayError as exc:
    print("Other SDK error:", exc)

Built-in help

print(client.help())
print(client.help("chat"))
print(client.help("errors"))

Command line

export JIBAYAI_API_KEY="YOUR_API_KEY"

jibayai chat "Hello" --model jibay-5
jibayai image "A futuristic city"
jibayai music "Calm jazz"
jibayai video "Autumn forest"
jibayai help errors

Use jibayai --help and jibayai <command> --help for all parameters.

Local development and test

python -m pip install -e .
python -m unittest discover -s tests -v

Build

python -m pip install --upgrade build twine
python -m build
python -m twine check dist/*

Publish to TestPyPI

python -m twine upload --repository testpypi dist/*

Publish to PyPI

python -m twine upload dist/*

When Twine asks for credentials, use __token__ as the username and your complete pypi-... token as the password.

Metadata

Release files for jibayai 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jibayai 0.1.0
File Size Uploaded
jibayai-0.1.0.tar.gz 15.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jibayai 0.1.0
File Interpreter ABI Platform
jibayai-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 30.9 kB

Release files / jibayai-0.1.0.tar.gz

Download URL jibayai-0.1.0.tar.gz
Size 15.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5bc6a62f1d91b40b865876c5f9a315c63422d800f73bd67c7364a28b9d0a83e1
BLAKE2b-256 checksum
How to use checksums
cc5840524e367cfc2e504fc66bf758f8c43e6ab191732e8ade306b58c66575e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Release files / jibayai-0.1.0-py3-none-any.whl

Download URL jibayai-0.1.0-py3-none-any.whl
Size 15.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e1ebfc8acacbb769410dadf963fdaabb2f8317bf97be02c475c7e703a9da09df
BLAKE2b-256 checksum
How to use checksums
e74f1bebc5bfbd7f65b17d581f1211f0f1a86d06617494a7236c1ea9372efb08
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page