Use only one line of code to call multiple model APIs similar to ChatGPT. Currently supported: Azure OpenAI Resource endpoint API, OpenAI Official API, and Anthropic Claude series model API.
Project description
OneAPI
Use only one line of code to call multiple model APIs similar to ChatGPT. Currently supported: Azure OpenAI Resource endpoint API, OpenAI Official API, and Anthropic Claude series model API.
Installation
pip install -U one-api-tool
Usage
1. (Recommended method) Set your key information in the local configuration file.
OpenAI config:
{
"api_key": "YOUR_API_KEY",
"api": "https://api.openai.com/v1",
"api_type": "open_ai"
}
Azure OpenAI config:
{
"api_key": "YOUR_API_KEY",
"api": "Change to your Azure OpenAI resource's endpoint value.",
"api_type": "azure"
}
Antropic config:
{
"api_key": "YOUR_API_KEY",
"api": "https://api.anthropic.com",
"api_type": "claude"
}
api_key
OpenAI API key is availalle on the website, Clade API key here website
api
The base api used to send requests, you may also specify to a proxy url like: "https://your_proxy_domain/v1". For Azure APIs, you can find relevant information on the Azure resource dashboard, the form of API is usually: https://{your origization}.openai.azure.com/
api_type
Currently supported: "open_ai", "azure" or "claude".
Initialize the OneAPITool
object from a local configuration file.:
from oneapi import OneAPITool
res = OneAPITool.from_config_file("your_config_file.json").simple_chat("Hello AI!")
print(res)
2. (Not recommended) Writing the configuration directly into the code
from oneapi import OneAPITool
res = OneAPITool.from_config(api_key, api, api_type).simple_chat("Hello AI!")
print(res)
Project details
Release history Release notifications | RSS feed
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
Hashes for one_api_tool-0.2.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c38ff5979fff4dc990df68b71a7338e9453d16c620dc21e4c7a9276aadc9ec3 |
|
MD5 | 8340f2de7e2db9869b61ba8bb767f179 |
|
BLAKE2b-256 | 346baee828af59b92f50c8fc7a17fc8beb1c332ef3be6cc7109a5c26fa67d754 |