Skip to main content

ArizonaAI Python SDK

Профессиональная Python-библиотека для взаимодействия с API ArizonaAI.

Особенности

  • 🔄 Sync/Async — полная поддержка синхронных и асинхронных операций
  • 📦 Типизация — полные type hints и dataclass модели
  • 🔁 Retry Logic — автоматические повторы при ошибках
  • 📡 Streaming — потоковая передача ответов
  • ⚡ Модульность — отдельные API модули (chat, models, user, configs, forum)
  • 🛡️ Error Handling — детальные исключения для всех типов ошибок

Установка

pip install arizona_ai_sdk

Быстрый старт

Базовое использование

from arizona_ai_sdk import ArizonaAIClient

client = ArizonaAIClient(api_key="your-api-key")

response = client.ask("Какие правила Arizona RP?")
print(response)

Асинхронное использование

import asyncio
from arizona_ai_sdk import ArizonaAIClient

async def main():
    async with ArizonaAIClient(api_key="your-api-key") as client:
        response = await client.aask(model="arizona-lm-game", message="Расскажи про систему домов")
        print(response)

asyncio.run(main())

Работа с сообщениями

from arizona_ai_sdk import ArizonaAIClient, Message

client = ArizonaAIClient(api_key="your-api-key")

messages = [
    Message.system("Ты помощник по Arizona RP"),
    Message.user("Как получить лицензию на оружие?"),
]

completion = client.chat.completions(
    messages=messages,
    model="arizona-lm-game",
)

print(completion.content)

Streaming

from arizona_ai_sdk import ArizonaAIClient

client = ArizonaAIClient(api_key="your-api-key")

response = client.chat.stream(
    messages="Объясни систему организаций",
    model="arizona-lm-game",
    callback=lambda chunk: print(chunk, end="", flush=True)
)

Async Streaming

import asyncio
from arizona_ai_sdk import ArizonaAIClient

async def main():
    client = ArizonaAIClient(api_key="your-api-key")
    
    async for chunk in client.chat.astream("Расскажи про автосалоны"):
        print(chunk.content, end="", flush=True)
    
    await client.aclose()

asyncio.run(main())

API Модули

Chat API

client.chat.completions(messages, model, temperature, config_id, attachments)
client.chat.acompletions(...)
client.chat.stream(messages, callback=...)
client.chat.astream(messages)
client.chat.astream_text(messages)

Models API

models = client.models.list()
model = client.models.get("arizona-lm-forum")
available = client.models.get_available()
found = client.models.find("gemini")

User API

limits = client.user.get_limits()
is_valid = client.user.validate_token()
history = client.user.get_history(page=1, per_page=20)
can_request = client.user.can_make_request()

Configs API

configs = client.configs.list(scope="all")
config = client.configs.find_by_name("My Config")

Tokens API

count = client.tokens.count("Привет, мир!", model="arizona-lm-forum")
print(count.token_count)
print(count.exceeds_request_limit())

Forum API

servers = client.forum.get_servers()
category = client.forum.get_category(123)
thread = client.forum.get_thread(456)
post = client.forum.get_post(789)
member = client.forum.get_member(111)

threads = client.forum.get_category_threads(123, page=1)
posts = client.forum.get_thread_posts(456, page=1)

results = client.forum.search_threads("правила", sort="relevance")
members = client.forum.search_members("Admin")

Работа с вложениями

from arizona_ai_sdk import ArizonaAIClient
from arizona_ai_sdk.utils import file_to_attachment

client = ArizonaAIClient(api_key="your-api-key")

attachment = file_to_attachment("screenshot.png")

response = client.chat.completions(
    messages="Что на этом скриншоте?",
    model="gemini-2.5-flash",
    attachments=[attachment]
)

Обработка ошибок

from arizona_ai_sdk import ArizonaAIClient
from arizona_ai_sdk.exceptions import (
    AuthenticationError,
    RateLimitError,
    NotFoundError,
    ValidationError,
)

client = ArizonaAIClient(api_key="your-api-key")

try:
    response = client.ask("Вопрос")
except AuthenticationError:
    print("Неверный API ключ")
except RateLimitError as e:
    print(f"Превышен лимит. Подождите {e.retry_after} секунд")
except NotFoundError:
    print("Ресурс не найден")
except ValidationError as e:
    print(f"Ошибка валидации: {e.message}")

Конфигурация

client = ArizonaAIClient(
    api_key="your-api-key",
    base_url="https://arizona-ai.ru",
    timeout=60.0,
    max_retries=3,
    verify_ssl=True,
    custom_headers={"X-Custom-Header": "value"}
)

Модели данных

  • Message — сообщение чата
  • ChatCompletion — ответ на запрос
  • ChatCompletionChunk — чанк стриминга
  • Model — информация о модели
  • UserLimits — лимиты пользователя
  • TokenValidation — результат валидации токена
  • Config — конфигурация
  • TokenCount — подсчёт токенов
  • ForumThread, ForumPost, ForumMember — данные форума

Лицензия

GPL-2.0 license

Metadata

Release files for arizona-ai-sdk 1.0.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 arizona-ai-sdk 1.0.0
File Size Uploaded
arizona_ai_sdk-1.0.0.tar.gz 25.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for arizona-ai-sdk 1.0.0
File Interpreter ABI Platform
arizona_ai_sdk-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 55.5 kB

Release files / arizona_ai_sdk-1.0.0.tar.gz

Download URL arizona_ai_sdk-1.0.0.tar.gz
Size 25.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3c9e2ede0d9f69821ae5c3904281425e57b8c1dbdec2af119f4917a635e7aece
BLAKE2b-256 checksum
How to use checksums
f2a7b77d0cf8c44c8934494c24a06d5777121b181efbf89479014b6345567556
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.6

Release files / arizona_ai_sdk-1.0.0-py3-none-any.whl

Download URL arizona_ai_sdk-1.0.0-py3-none-any.whl
Size 29.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b822f69e50547ff5b9faa9e6cc0c6b3c5cb77fccab58eeaa39c7e92ad7589c6c
BLAKE2b-256 checksum
How to use checksums
f32f02da4464da019956c34049a3144c4736f6c437bdd84fd887ffc4979b7ac5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.6

Release history Release notifications | RSS feed

This release

1.0.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