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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jibayai-0.1.0.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jibayai-0.1.0-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file jibayai-0.1.0.tar.gz.

File metadata

  • Download URL: jibayai-0.1.0.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for jibayai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5bc6a62f1d91b40b865876c5f9a315c63422d800f73bd67c7364a28b9d0a83e1
MD5 66c947068718c6445488e674bda34da8
BLAKE2b-256 cc5840524e367cfc2e504fc66bf758f8c43e6ab191732e8ade306b58c66575e3

See more details on using hashes here.

File details

Details for the file jibayai-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: jibayai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for jibayai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e1ebfc8acacbb769410dadf963fdaabb2f8317bf97be02c475c7e703a9da09df
MD5 f01733e932180429e5b18f73c22db19f
BLAKE2b-256 e74f1bebc5bfbd7f65b17d581f1211f0f1a86d06617494a7236c1ea9372efb08

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page