A minimalist Python package scaffolded with uv
Project description
oiiai
oiiai 是一个简单的 AI 模型调用工具包,提供模型列表获取和模型调用功能。
特性
- 🚀 支持多个 AI 提供商的模型列表获取
- 📦 统一的 API 接口
- 🛠️ 简单易用的设计
- 🔧 可扩展的架构
支持的提供商
| 提供商 | 模型获取 | 说明 |
|---|---|---|
| 智谱 AI | ✅ FetchZhipu | 从官方文档页面解析模型列表 |
| OpenRouter | ✅ FetchOpenRouter | 通过 API 获取模型列表 |
| ModelScope | ✅ FetchModelScope | 通过 API 获取模型列表 |
| SiliconFlow | ✅ FetchSiliconFlow | 通过 API 获取模型列表 |
| IFlow | ✅ FetchIFlow | 通过 API 获取模型列表 |
安装
使用 pip
pip install oiiai-lib
使用 uv
uv add oiiai-lib
快速开始
from oiiai import (
FetchZhipu,
FetchOpenRouter,
FetchModelScope,
FetchSiliconFlow,
FetchIFlow,
)
# 获取可用模型列表
# 从智谱 AI 获取模型列表
zhipu_fetcher = FetchZhipu()
zhipu_models = zhipu_fetcher.fetch_models()
print(f"智谱 AI 可用模型: {len(zhipu_models)} 个")
# 从 OpenRouter 获取模型列表
openrouter_fetcher = FetchOpenRouter(api_key="your-api-key")
openrouter_models = openrouter_fetcher.fetch_models()
print(f"OpenRouter 可用模型: {len(openrouter_models)} 个")
# 从 ModelScope 获取模型列表
modelscope_fetcher = FetchModelScope()
modelscope_models = modelscope_fetcher.fetch_models()
print(f"ModelScope 可用模型: {len(modelscope_models)} 个")
# 从 SiliconFlow 获取模型列表
siliconflow_fetcher = FetchSiliconFlow()
siliconflow_models = siliconflow_fetcher.fetch_models()
print(f"SiliconFlow 可用模型: {len(siliconflow_models)} 个")
# 从 IFlow 获取模型列表
iflow_fetcher = FetchIFlow()
iflow_models = iflow_fetcher.fetch_models()
print(f"IFlow 可用模型: {len(iflow_models)} 个")
API 参考
基类 FetchBase
所有模型获取器的抽象基类。
from oiiai import FetchBase
class MyFetcher(FetchBase):
@property
def provider(self) -> str:
return "my_provider"
def fetch_models(self) -> List[str]:
# 实现获取逻辑
return ["model-1", "model-2"]
FetchOpenRouter
从 OpenRouter API 获取模型列表。
from oiiai import FetchOpenRouter
# 使用 API Key(可选,不传则从环境变量 OPENROUTER_API_KEY 获取)
fetcher = FetchOpenRouter(api_key="your-api-key")
# 获取模型列表
models = fetcher.fetch_models()
print(models) # ['openai/gpt-4o', 'anthropic/claude-3-opus', ...]
FetchZhipu
从智谱 AI 官方文档页面解析模型列表。
from oiiai import FetchZhipu
fetcher = FetchZhipu()
models = fetcher.fetch_models()
print(models) # ['glm-4-flash', 'glm-4', ...]
FetchModelScope
从 ModelScope API 获取模型列表。
from oiiai import FetchModelScope
fetcher = FetchModelScope()
models = fetcher.fetch_models()
print(models) # ['deepseek-ai/DeepSeek-R1-0528', 'Qwen/Qwen2.5-72B-Instruct', ...]
FetchSiliconFlow
从 SiliconFlow API 获取模型列表。需要设置环境变量 SILICONFLOW_API_KEY。
from oiiai import FetchSiliconFlow
fetcher = FetchSiliconFlow()
models = fetcher.fetch_models()
print(models) # ['deepseek-ai/DeepSeek-R1', 'Qwen/Qwen2.5-72B-Instruct', ...]
FetchIFlow
从 IFlow 平台获取模型列表。
from oiiai import FetchIFlow
fetcher = FetchIFlow()
models = fetcher.fetch_models()
print(models) # ['qwen3-max', 'deepseek-r1', 'kimi-k2', ...]
开发
克隆仓库
git clone https://github.com/weisiren000/oiiai
cd oiiai
安装开发依赖
uv sync --dev
运行测试
uv run pytest
代码格式化
uv run ruff format .
uv run ruff check .
扩展
实现自定义获取器只需继承 FetchBase 并实现 provider 属性和 fetch_models() 方法。
许可证
MIT License. 详见 LICENSE 文件。
贡献
欢迎提交 Issue 和 Pull Request!
链接
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file oiiai_lib-0.0.2.tar.gz.
File metadata
- Download URL: oiiai_lib-0.0.2.tar.gz
- Upload date:
- Size: 81.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10f80949b95d689f897a1285393984a7f442e6824bb17f787b48cb1f9b460517
|
|
| MD5 |
7c4cef361a3d3c43794efb1bcb3b97f1
|
|
| BLAKE2b-256 |
6ce34f58f9c02f1f3e6f24149a02f0c10b8b1aec8cefa7e8740fb083360cf7c2
|
File details
Details for the file oiiai_lib-0.0.2-py3-none-any.whl.
File metadata
- Download URL: oiiai_lib-0.0.2-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d47cfb66970d408ae3f34099758aeb0a7e56d56f9cfa90e73c9aa02457e3b59
|
|
| MD5 |
351f7d49c09c5f20a4d1f1c9ce165635
|
|
| BLAKE2b-256 |
6e8f1b822ef5dc231f0691b5f928c939ad9a081279cb7f5601e70a3fcbc6e368
|