xmode-ai-sdk 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,24 @@
1
+ Metadata-Version: 2.4
2
+ Name: xmode-ai-sdk
3
+ Version: 1.0.0
4
+ Summary: Python client for XMode AI – access multiple AI models with one API key
5
+ Home-page: https://xmode.space
6
+ Author: XMode Team
7
+ Author-email: support@xmode.space
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.7
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: requests>=2.25.0
14
+ Dynamic: author
15
+ Dynamic: author-email
16
+ Dynamic: classifier
17
+ Dynamic: description
18
+ Dynamic: description-content-type
19
+ Dynamic: home-page
20
+ Dynamic: requires-dist
21
+ Dynamic: requires-python
22
+ Dynamic: summary
23
+
24
+ XMode AI Python client for accessing multiple AI models via one API key.
@@ -0,0 +1,90 @@
1
+ # 🚀 XMode AI Python Client
2
+
3
+ **XMode AI** is a unified Python client for advanced AI models from **Anthropic**, **OpenAI**, and **Google Gemini**.
4
+ One API key – access to all leading models.
5
+
6
+ ---
7
+
8
+ ## 📦 Installation
9
+
10
+ ```bash
11
+ # From source (recommended for development)
12
+ pip install -e .
13
+
14
+ # After publishing to PyPI
15
+ pip install xmode-ai
16
+ ```
17
+
18
+ ---
19
+
20
+ ## 🚀 Quick Start
21
+
22
+ ```python
23
+ from xmode_ai import XModeAI
24
+
25
+ # Your personal API key from xmode.space dashboard
26
+ ai = XModeAI(api_key="your-api-key")
27
+
28
+ # Simple chat
29
+ reply = ai.simple_chat("What is the capital of France?")
30
+ print(reply)
31
+ ```
32
+
33
+ ---
34
+
35
+ ## 🧠 Available Models
36
+
37
+ ```python
38
+ from xmode_ai import list_models
39
+
40
+ for model in list_models():
41
+ print(f"{model['id']} – {model['name']} ({model['context']} ctx)")
42
+ ```
43
+
44
+ ### Model List (sample)
45
+
46
+ | Provider | Model | Context | Price (input/output per 1M tokens) |
47
+ |-----------|--------------------|---------|-----------------------------------|
48
+ | Anthropic | Claude Opus 5 | 200K | $2.50 / $12.50 |
49
+ | Anthropic | Claude Sonnet 5 | 200K | $1.00 / $5.00 |
50
+ | OpenAI | GPT-5.6 Sol | 400K | $2.50 / $15.00 |
51
+ | OpenAI | GPT-5.5 | 400K | $2.50 / $15.00 |
52
+ | Google | Gemini 3.1 Pro | 2M | $1.00 / $6.00 |
53
+ | Google | Gemini 3.6 Flash | 1M | $0.75 / $3.75 |
54
+
55
+ Full model list with all parameters is available in `xmode_ai.models`.
56
+
57
+ ---
58
+
59
+ ## ⚙️ Advanced Usage
60
+
61
+ ```python
62
+ from xmode_ai import XModeAI
63
+
64
+ ai = XModeAI(api_key="your-api-key")
65
+
66
+ response = ai.chat_completion(
67
+ messages=[
68
+ {"role": "system", "content": "You are a helpful assistant."},
69
+ {"role": "user", "content": "Explain quantum computing in simple terms."}
70
+ ],
71
+ model="claude-sonnet-5",
72
+ temperature=0.5,
73
+ max_tokens=500
74
+ )
75
+
76
+ print(response["choices"][0]["message"]["content"])
77
+ ```
78
+
79
+ ---
80
+
81
+ ## 📚 Documentation
82
+
83
+ - Official website: [xmode.space](https://xmode.space)
84
+ - Support: [support@xmode.space](mailto:support@xmode.space)
85
+
86
+ ---
87
+
88
+ ## 📄 License
89
+
90
+ MIT License © 2026 XMode Team
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,20 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="xmode-ai-sdk",
5
+ version="1.0.0",
6
+ description="Python client for XMode AI – access multiple AI models with one API key",
7
+ long_description="XMode AI Python client for accessing multiple AI models via one API key.",
8
+ long_description_content_type="text/markdown",
9
+ author="XMode Team",
10
+ author_email="support@xmode.space",
11
+ url="https://xmode.space",
12
+ packages=find_packages(),
13
+ install_requires=["requests>=2.25.0"],
14
+ python_requires=">=3.7",
15
+ classifiers=[
16
+ "Programming Language :: Python :: 3",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Operating System :: OS Independent",
19
+ ],
20
+ )
@@ -0,0 +1,18 @@
1
+ """
2
+ XMode AI — Python клиент для работы с AI моделями.
3
+ Используйте свой API-ключ, полученный в личном кабинете xmode.space.
4
+ """
5
+ from .core import XModeAI
6
+ from .models import MODELS, list_models, get_model_info
7
+ from .exceptions import XModeError, APIError, AuthenticationError
8
+
9
+ __all__ = [
10
+ "XModeAI",
11
+ "MODELS",
12
+ "list_models",
13
+ "get_model_info",
14
+ "XModeError",
15
+ "APIError",
16
+ "AuthenticationError",
17
+ ]
18
+ __version__ = "1.0.0"
@@ -0,0 +1,66 @@
1
+ """
2
+ Основной клиент для взаимодействия с XMode AI API.
3
+ """
4
+ import requests
5
+ from typing import List, Dict, Any, Optional
6
+ from .exceptions import AuthenticationError, APIError
7
+ from .models import get_model_info
8
+
9
+ class XModeAI:
10
+ """
11
+ Клиент для XMode AI.
12
+ Использует единый API-ключ, полученный в личном кабинете xmode.space.
13
+ По умолчанию отправляет запросы на https://api.xmode.space/v1.
14
+ """
15
+ def __init__(self, api_key: str, base_url: str = "https://api.xmode.space/v1"):
16
+ self.api_key = api_key
17
+ self.base_url = base_url.rstrip('/')
18
+ self.headers = {
19
+ "Authorization": f"Bearer {self.api_key}",
20
+ "Content-Type": "application/json"
21
+ }
22
+
23
+ def _request(self, method: str, endpoint: str, data: Dict = None) -> Dict:
24
+ url = f"{self.base_url}/{endpoint.lstrip('/')}"
25
+ try:
26
+ response = requests.request(
27
+ method=method,
28
+ url=url,
29
+ headers=self.headers,
30
+ json=data,
31
+ timeout=60
32
+ )
33
+ if response.status_code == 401:
34
+ raise AuthenticationError("Invalid API key.")
35
+ if response.status_code >= 400:
36
+ raise APIError(f"API error {response.status_code}: {response.text}")
37
+ return response.json()
38
+ except requests.exceptions.RequestException as e:
39
+ raise APIError(f"Network error: {e}")
40
+
41
+ def chat_completion(
42
+ self,
43
+ messages: List[Dict[str, str]],
44
+ model: str = "gpt-3.5-turbo",
45
+ temperature: float = 0.7,
46
+ max_tokens: int = 1000,
47
+ **kwargs
48
+ ) -> Dict[str, Any]:
49
+ """Отправить запрос на завершение чата."""
50
+ payload = {
51
+ "model": model,
52
+ "messages": messages,
53
+ "temperature": temperature,
54
+ "max_tokens": max_tokens,
55
+ **kwargs
56
+ }
57
+ return self._request("POST", "/chat/completions", payload)
58
+
59
+ def simple_chat(self, prompt: str, model: str = "gpt-3.5-turbo", **kwargs) -> str:
60
+ """Упрощённый метод: отправляет один промпт, возвращает текст ответа."""
61
+ messages = [{"role": "user", "content": prompt}]
62
+ result = self.chat_completion(messages, model=model, **kwargs)
63
+ try:
64
+ return result["choices"][0]["message"]["content"]
65
+ except (KeyError, IndexError):
66
+ raise APIError("Unexpected response format.")
@@ -0,0 +1,13 @@
1
+ """Кастомные исключения для библиотеки."""
2
+
3
+ class XModeError(Exception):
4
+ """Базовое исключение XMode AI."""
5
+ pass
6
+
7
+ class AuthenticationError(XModeError):
8
+ """Ошибка аутентификации (неверный API-ключ)."""
9
+ pass
10
+
11
+ class APIError(XModeError):
12
+ """Ошибка при вызове API (сетевая или серверная)."""
13
+ pass
@@ -0,0 +1,80 @@
1
+ """
2
+ Список доступных моделей, сгруппированных по провайдерам.
3
+ Актуально на август 2026.
4
+ """
5
+ MODELS = {
6
+ "anthropic": [
7
+ {"id": "claude-opus-5", "name": "Claude Opus 5", "context": 200000,
8
+ "description": "Flagship model for demanding reasoning, coding, and long-horizon agentic work",
9
+ "input_price": 2.5, "output_price": 12.5},
10
+ {"id": "claude-sonnet-5", "name": "Claude Sonnet 5", "context": 200000,
11
+ "description": "The most powerful Sonnet model, excelling at coding, agentic, and professional tasks",
12
+ "input_price": 1.0, "output_price": 5.0},
13
+ {"id": "claude-opus-4.8", "name": "Claude Opus 4.8", "context": 200000,
14
+ "description": "Newest Opus — top-tier coding, analysis, and long-horizon tasks",
15
+ "input_price": 2.5, "output_price": 12.5},
16
+ {"id": "claude-opus-4.7", "name": "Claude Opus 4.7", "context": 200000,
17
+ "description": "Most capable Claude for deep reasoning and agentic work",
18
+ "input_price": 2.5, "output_price": 12.5},
19
+ {"id": "claude-sonnet-4.6", "name": "Claude Sonnet 4.6", "context": 200000,
20
+ "description": "Balanced Claude with strong quality at a moderate price",
21
+ "input_price": 1.5, "output_price": 7.5},
22
+ {"id": "claude-haiku-4.5", "name": "Claude Haiku 4.5", "context": 200000,
23
+ "description": "Fastest, most affordable Claude for everyday tasks",
24
+ "input_price": 0.5, "output_price": 2.5},
25
+ ],
26
+ "openai": [
27
+ {"id": "gpt-5.6-sol", "name": "GPT-5.6 Sol", "context": 400000,
28
+ "description": "Flagship model in the GPT-5.6 series",
29
+ "input_price": 2.5, "output_price": 15.0},
30
+ {"id": "gpt-5.5", "name": "GPT-5.5", "context": 400000,
31
+ "description": "Latest frontier model with the strongest general capabilities",
32
+ "input_price": 2.5, "output_price": 15.0},
33
+ {"id": "gpt-5.6-terra", "name": "GPT-5.6 Terra", "context": 400000,
34
+ "description": "Balanced capability and cost for coding, reasoning, and agentic tasks",
35
+ "input_price": 1.25, "output_price": 7.5},
36
+ {"id": "gpt-5.6-luna", "name": "GPT-5.6 Luna", "context": 400000,
37
+ "description": "High-volume and latency‑sensitive tasks (chat, classification)",
38
+ "input_price": 0.5, "output_price": 3.0},
39
+ {"id": "gpt-5.4", "name": "GPT-5.4", "context": 400000,
40
+ "description": "Higher‑quality reasoning for complex, multi‑step tasks",
41
+ "input_price": 1.25, "output_price": 7.5},
42
+ {"id": "gpt-5.4-mini", "name": "GPT-5.4 Mini", "context": 400000,
43
+ "description": "Fast and cheap for high‑volume, latency‑sensitive workloads",
44
+ "input_price": 0.38, "output_price": 2.25},
45
+ ],
46
+ "google": [
47
+ {"id": "gemini-3.1-pro", "name": "Gemini 3.1 Pro", "context": 2000000,
48
+ "description": "Refined Gemini 3 Pro with 2M‑token context",
49
+ "input_price": 1.0, "output_price": 6.0},
50
+ {"id": "gemini-3.6-flash", "name": "Gemini 3.6 Flash", "context": 1000000,
51
+ "description": "High‑quality results with reduced token usage and fewer edits",
52
+ "input_price": 0.75, "output_price": 3.75},
53
+ {"id": "gemini-3.5-flash", "name": "Gemini 3.5 Flash", "context": 1000000,
54
+ "description": "Latest Flash generation, optimised for speed and scale",
55
+ "input_price": 0.75, "output_price": 4.5},
56
+ {"id": "gemini-2.5-flash", "name": "Gemini 2.5 Flash", "context": 1000000,
57
+ "description": "Fast, low‑cost multimodal model with huge context window",
58
+ "input_price": 0.15, "output_price": 1.25},
59
+ {"id": "gemini-2.5-pro", "name": "Gemini 2.5 Pro", "context": 1000000,
60
+ "description": "High‑quality reasoning across text, images, and code",
61
+ "input_price": 0.63, "output_price": 5.0},
62
+ ],
63
+ }
64
+
65
+ def list_models(provider=None):
66
+ """Возвращает список моделей. Если provider указан, фильтрует по провайдеру."""
67
+ if provider:
68
+ return MODELS.get(provider.lower(), [])
69
+ all_models = []
70
+ for group in MODELS.values():
71
+ all_models.extend(group)
72
+ return all_models
73
+
74
+ def get_model_info(model_id):
75
+ """Возвращает информацию о модели по её ID или None."""
76
+ for group in MODELS.values():
77
+ for model in group:
78
+ if model["id"] == model_id:
79
+ return model
80
+ return None
@@ -0,0 +1,24 @@
1
+ Metadata-Version: 2.4
2
+ Name: xmode-ai-sdk
3
+ Version: 1.0.0
4
+ Summary: Python client for XMode AI – access multiple AI models with one API key
5
+ Home-page: https://xmode.space
6
+ Author: XMode Team
7
+ Author-email: support@xmode.space
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.7
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: requests>=2.25.0
14
+ Dynamic: author
15
+ Dynamic: author-email
16
+ Dynamic: classifier
17
+ Dynamic: description
18
+ Dynamic: description-content-type
19
+ Dynamic: home-page
20
+ Dynamic: requires-dist
21
+ Dynamic: requires-python
22
+ Dynamic: summary
23
+
24
+ XMode AI Python client for accessing multiple AI models via one API key.
@@ -0,0 +1,11 @@
1
+ README.md
2
+ setup.py
3
+ xmode_ai/__init__.py
4
+ xmode_ai/core.py
5
+ xmode_ai/exceptions.py
6
+ xmode_ai/models.py
7
+ xmode_ai_sdk.egg-info/PKG-INFO
8
+ xmode_ai_sdk.egg-info/SOURCES.txt
9
+ xmode_ai_sdk.egg-info/dependency_links.txt
10
+ xmode_ai_sdk.egg-info/requires.txt
11
+ xmode_ai_sdk.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ requests>=2.25.0
@@ -0,0 +1 @@
1
+ xmode_ai