Englisch | chinesisch
Für den persönlichen Gebrauch ist ein/New-API zu komplex mit vielen kommerziellen Funktionen, die Einzelpersonen nicht benötigen. Wenn Sie keine komplizierte Frontend-Schnittstelle wünschen und Unterstützung für mehr Modelle bevorzugen, können Sie Uni-API ausprobieren. Dies ist ein Projekt, das das Management von APIs mit großer Sprache vereint, sodass Sie mehrere Backend -Dienste über eine einzelne einheitliche API -Schnittstelle aufrufen, alle in das OpenAI -Format umwandeln und Lastausgleich unterstützen. Zu den derzeit unterstützten Backend -Diensten gehören: OpenAI, Anthropic, Gemini, Vertex, Cohere, GROQ, Cloudflare, OpenRouter und mehr.
SCHEDULING_ALGORITHM
als round_robin
./v1/chat/completions
, /v1/images/generations
, /v1/audio/transcriptions
, /v1/moderations
, /v1/models
.Um Uni-API zu starten, muss eine Konfigurationsdatei verwendet werden. Es gibt zwei Möglichkeiten, mit einer Konfigurationsdatei zu beginnen:
CONFIG_URL
zu verwenden, um die URL der Konfigurationsdatei einzugeben, die beim Starten von UNI-API automatisch heruntergeladen wird.api.yaml
in den Container zu montieren.api.yaml
Konfigurationsdatei, um die UNI-API zu starten Sie müssen die Konfigurationsdatei im Voraus ausfüllen, um uni-api
zu starten, und Sie müssen eine Konfigurationsdatei mit dem Namen api.yaml
verwenden, um uni-api
zu starten. Sie können mehrere Modelle konfigurieren. Jedes Modell kann mehrere Backend-Dienste konfigurieren und Lastausgleich unterstützen. Nachfolgend finden Sie ein Beispiel für die minimale api.yaml
-Konfigurationsdatei, die ausgeführt werden kann:
providers :
- provider : provider_name # Service provider name, such as openai, anthropic, gemini, openrouter, can be any name, required
base_url : https://api.your.com/v1/chat/completions # Backend service API address, required
api : sk-YgS6GTi0b4bEabc4C # Provider's API Key, required, automatically uses base_url and api to get all available models through the /v1/models endpoint.
# Multiple providers can be configured here, each provider can configure multiple API Keys, and each API Key can configure multiple models.
api_keys :
- api : sk-Pkj60Yf8JFWxfgRmXQFWyGtWUddGZnmi3KlvowmRWpWpQxx # API Key, user request uni-api requires API key, required
# This API Key can use all models, that is, it can use all models in all channels set under providers, without needing to add available channels one by one.
Detaillierte erweiterte Konfiguration von api.yaml
:
providers :
- provider : provider_name # Service provider name, such as openai, anthropic, gemini, openrouter, can be any name, required
base_url : https://api.your.com/v1/chat/completions # Backend service API address, required
api : sk-YgS6GTi0b4bEabc4C # Provider's API Key, required
model : # Optional, if model is not configured, all available models will be automatically obtained through base_url and api via the /v1/models endpoint.
- gpt-4o # Usable model name, required
- claude-3-5-sonnet-20240620 : claude-3-5-sonnet # Rename model, claude-3-5-sonnet-20240620 is the provider's model name, claude-3-5-sonnet is the renamed name, you can use a simple name to replace the original complex name, optional
- dall-e-3
- provider : anthropic
base_url : https://api.anthropic.com/v1/messages
api : # Supports multiple API Keys, multiple keys automatically enable polling load balancing, at least one key, required
- sk-ant-api03-bNnAOJyA-xQw_twAA
- sk-ant-api02-bNnxxxx
model :
- claude-3-5-sonnet-20240620 : claude-3-5-sonnet # Rename model, claude-3-5-sonnet-20240620 is the provider's model name, claude-3-5-sonnet is the renamed name, you can use a simple name to replace the original complex name, optional
tools : true # Whether to support tools, such as generating code, generating documents, etc., default is true, optional
- provider : gemini
base_url : https://generativelanguage.googleapis.com/v1beta # base_url supports v1beta/v1, only for Gemini model use, required
api : # Supports multiple API Keys, multiple keys automatically enable polling load balancing, at least one key, required
- AIzaSyAN2k6IRdgw123
- AIzaSyAN2k6IRdgw456
- AIzaSyAN2k6IRdgw789
model :
- gemini-1.5-pro
- gemini-1.5-flash-exp-0827 : gemini-1.5-flash # After renaming, the original model name gemini-1.5-flash-exp-0827 cannot be used, if you want to use the original name, you can add the original name in the model, just add the line below to use the original name
- gemini-1.5-flash-exp-0827 # Add this line, both gemini-1.5-flash-exp-0827 and gemini-1.5-flash can be requested
tools : true
preferences :
api_key_rate_limit : 15/min # Each API Key can request up to 15 times per minute, optional. The default is 999999/min. Supports multiple frequency constraints: 15/min,10/day
# api_key_rate_limit: # You can set different frequency limits for each model
# gemini-1.5-flash: 15/min,1500/day
# gemini-1.5-pro: 2/min,50/day
# default: 4/min # If the model does not set the frequency limit, use the frequency limit of default
api_key_cooldown_period : 60 # Each API Key will be cooled down for 60 seconds after encountering a 429 error. Optional, the default is 0 seconds. When set to 0, the cooling mechanism is not enabled. When there are multiple API keys, the cooling mechanism will take effect.
api_key_schedule_algorithm : round_robin # Set the request order of multiple API Keys, optional. The default is round_robin, and the optional values are: round_robin, random. It will take effect when there are multiple API keys. round_robin is polling load balancing, and random is random load balancing.
model_timeout : # Model timeout, in seconds, default 100 seconds, optional
gemini-1.5-pro : 10 # Model gemini-1.5-pro timeout is 10 seconds
gemini-1.5-flash : 10 # Model gemini-1.5-flash timeout is 10 seconds
default : 10 # Model does not have a timeout set, use the default timeout of 10 seconds, when requesting a model not in model_timeout, the timeout is also 10 seconds, if default is not set, uni-api will use the default timeout set by the environment variable TIMEOUT, the default timeout is 100 seconds
proxy : socks5://[username]:[password]@[ip]:[port] # Proxy address, optional. Supports socks5 and http proxies, default is not used.
- provider : vertex
project_id : gen-lang-client-xxxxxxxxxxxxxx # Description: Your Google Cloud project ID. Format: String, usually composed of lowercase letters, numbers, and hyphens. How to obtain: You can find your project ID in the project selector of the Google Cloud Console.
private_key : " -----BEGIN PRIVATE KEY----- n xxxxx n -----END PRIVATE " # Description: Private key for Google Cloud Vertex AI service account. Format: A JSON formatted string containing the private key information of the service account. How to obtain: Create a service account in Google Cloud Console, generate a JSON formatted key file, and then set its content as the value of this environment variable.
client_email : [email protected] # Description: Email address of the Google Cloud Vertex AI service account. Format: Usually a string like "[email protected]". How to obtain: Generated when creating a service account, or you can view the service account details in the "IAM and Admin" section of the Google Cloud Console.
model :
- gemini-1.5-pro
- gemini-1.5-flash
- gemini-1.5-pro : gemini-1.5-pro-search # Only supports using the gemini-1.5-pro-search model to request uni-api when using the Vertex Gemini API, to automatically use the Google official search tool.
- claude-3-5-sonnet@20240620 : claude-3-5-sonnet
- claude-3-opus@20240229 : claude-3-opus
- claude-3-sonnet@20240229 : claude-3-sonnet
- claude-3-haiku@20240307 : claude-3-haiku
tools : true
notes : https://xxxxx.com/ # You can put the provider's website, notes, official documentation, optional
- provider : cloudflare
api : f42b3xxxxxxxxxxq4aoGAh # Cloudflare API Key, required
cf_account_id : 8ec0xxxxxxxxxxxxe721 # Cloudflare Account ID, required
model :
- ' @cf/meta/llama-3.1-8b-instruct ' : llama-3.1-8b # Rename model, @cf/meta/llama-3.1-8b-instruct is the provider's original model name, must be enclosed in quotes, otherwise yaml syntax error, llama-3.1-8b is the renamed name, you can use a simple name to replace the original complex name, optional
- ' @cf/meta/llama-3.1-8b-instruct ' # Must be enclosed in quotes, otherwise yaml syntax error
- provider : other-provider
base_url : https://api.xxx.com/v1/messages
api : sk-bNnAOJyA-xQw_twAA
model :
- causallm-35b-beta2ep-q6k : causallm-35b
- anthropic/claude-3-5-sonnet
tools : false
engine : openrouter # Force the use of a specific message format, currently supports gpt, claude, gemini, openrouter native format, optional
api_keys :
- api : sk-KjjI60Yf0JFWxfgRmXqFWyGtWUd9GZnmi3KlvowmRWpWpQRo # API Key, required for users to use this service
model : # Models that can be used by this API Key, required. Default channel-level polling load balancing is enabled, and each request model is requested in sequence according to the model configuration. It is not related to the original channel order in providers. Therefore, you can set different request sequences for each API key.
- gpt-4o # Usable model name, can use all gpt-4o models provided by providers
- claude-3-5-sonnet # Usable model name, can use all claude-3-5-sonnet models provided by providers
- gemini/* # Usable model name, can only use all models provided by providers named gemini, where gemini is the provider name, * represents all models
role : admin
- api : sk-pkhf60Yf0JGyJxgRmXqFQyTgWUd9GZnmi3KlvowmRWpWqrhy
model :
- anthropic/claude-3-5-sonnet # Usable model name, can only use the claude-3-5-sonnet model provided by the provider named anthropic. Models with the same name from other providers cannot be used. This syntax will not match the model named anthropic/claude-3-5-sonnet provided by other-provider.
- <anthropic/claude-3-5-sonnet> # By adding angle brackets on both sides of the model name, it will not search for the claude-3-5-sonnet model under the channel named anthropic, but will take the entire anthropic/claude-3-5-sonnet as the model name. This syntax can match the model named anthropic/claude-3-5-sonnet provided by other-provider. But it will not match the claude-3-5-sonnet model under anthropic.
- openai-test/text-moderation-latest # When message moderation is enabled, the text-moderation-latest model under the channel named openai-test can be used for moderation.
- sk-KjjI60Yd0JFWtxxxxxxxxxxxxxxwmRWpWpQRo/* # Support using other API keys as channels
preferences :
SCHEDULING_ALGORITHM : fixed_priority # When SCHEDULING_ALGORITHM is fixed_priority, use fixed priority scheduling, always execute the channel of the first model with a request. Default is enabled, SCHEDULING_ALGORITHM default value is fixed_priority. SCHEDULING_ALGORITHM optional values are: fixed_priority, round_robin, weighted_round_robin, lottery, random.
# When SCHEDULING_ALGORITHM is random, use random polling load balancing, randomly request the channel of the model with a request.
# When SCHEDULING_ALGORITHM is round_robin, use polling load balancing, request the channel of the model used by the user in order.
AUTO_RETRY : true # Whether to automatically retry, automatically retry the next provider, true for automatic retry, false for no automatic retry, default is true. Also supports setting a number, indicating the number of retries.
rate_limit : 15/min # Supports rate limiting, each API Key can request up to 15 times per minute, optional. The default is 999999/min. Supports multiple frequency constraints: 15/min,10/day
# rate_limit: # You can set different frequency limits for each model
# gemini-1.5-flash: 15/min,1500/day
# gemini-1.5-pro: 2/min,50/day
# default: 4/min # If the model does not set the frequency limit, use the frequency limit of default
ENABLE_MODERATION : true # Whether to enable message moderation, true for enable, false for disable, default is false, when enabled, it will moderate the user's message, if inappropriate messages are found, an error message will be returned.
# Channel-level weighted load balancing configuration example
- api : sk-KjjI60Yd0JFWtxxxxxxxxxxxxxxwmRWpWpQRo
model :
- gcp1/* : 5 # The number after the colon is the weight, weight only supports positive integers.
- gcp2/* : 3 # The size of the number represents the weight, the larger the number, the greater the probability of the request.
- gcp3/* : 2 # In this example, there are a total of 10 weights for all channels, and 10 requests will have 5 requests for the gcp1/* model, 2 requests for the gcp2/* model, and 3 requests for the gcp3/* model.
preferences :
SCHEDULING_ALGORITHM : weighted_round_robin # Only when SCHEDULING_ALGORITHM is weighted_round_robin and the above channel has weights, it will request according to the weighted order. Use weighted polling load balancing, request the channel of the model with a request according to the weight order. When SCHEDULING_ALGORITHM is lottery, use lottery polling load balancing, request the channel of the model with a request according to the weight randomly. Channels without weights automatically fall back to round_robin polling load balancing.
AUTO_RETRY : true
preferences : # Global configuration
model_timeout : # Model timeout, in seconds, default 100 seconds, optional
gpt-4o : 10 # Model gpt-4o timeout is 10 seconds, gpt-4o is the model name, when requesting models like gpt-4o-2024-08-06, the timeout is also 10 seconds
claude-3-5-sonnet : 10 # Model claude-3-5-sonnet timeout is 10 seconds, when requesting models like claude-3-5-sonnet-20240620, the timeout is also 10 seconds
default : 10 # Model does not have a timeout set, use the default timeout of 10 seconds, when requesting a model not in model_timeout, the default timeout is 10 seconds, if default is not set, uni-api will use the default timeout set by the environment variable TIMEOUT, the default timeout is 100 seconds
o1-mini : 30 # Model o1-mini timeout is 30 seconds, when requesting models starting with o1-mini, the timeout is 30 seconds
o1-preview : 100 # Model o1-preview timeout is 100 seconds, when requesting models starting with o1-preview, the timeout is 100 seconds
cooldown_period : 300 # Channel cooldown time, in seconds, default 300 seconds, optional. When a model request fails, the channel will be automatically excluded and cooled down for a period of time, and will not request the channel again. After the cooldown time ends, the model will be automatically restored until the request fails again, and it will be cooled down again. When cooldown_period is set to 0, the cooling mechanism is not enabled.
error_triggers : # Error triggers, when the message returned by the model contains any of the strings in the error_triggers, the channel will return an error. Optional
- The bot's usage is covered by the developer
- process this request due to overload or policy
Montieren Sie die Konfigurationsdatei und starten Sie den Uni-API-Docker-Container:
docker run --user root -p 8001:8000 --name uni-api -dit
-v ./api.yaml:/home/api.yaml
yym68686/uni-api:latest
CONFIG_URL
Nach dem Schreiben der Konfigurationsdatei gemäß Methode 1 laden Sie sie auf die Cloud-Festplatte hoch, erhalten Sie den direkten Link der Datei und verwenden Sie die Umgebungsvariable CONFIG_URL
, um den Uni-API-Docker-Container zu starten:
docker run --user root -p 8001:8000 --name uni-api -dit
-e CONFIG_URL=http://file_url/api.yaml
yym68686/uni-api:latest
Nachdem Sie oben auf die One-Click-Bereitstellung geklickt haben, setzen Sie die Umgebungsvariable CONFIG_URL
auf den direkten Link der Konfigurationsdatei, DISABLE_DATABASE
auf true und klicken Sie dann auf Erstellen des Projekts. Nach der Bereitstellung müssen Sie die Funktion maximal maximal auf 60 Sekunden im Vercel -Projektbereich unter Einstellungen -> Funktionen einstellen, und klicken Sie dann auf das Menü Bereitstellungen und klicken Sie auf Neueinstellung, um die Zeitüberschreitung auf 60 Sekunden festzulegen. Wenn Sie nicht neu anwenden, bleibt das Standard -Timeout bei den ursprünglichen 10 Sekunden. Beachten Sie, dass Sie das Vercel -Projekt nicht löschen und es neu erstellen sollten. Klicken Sie stattdessen im Menü Bereitstellungsmenü im aktuell bereitgestellten Vercel -Projekt auf dem neuesten Stand, um die maximale Dauermodifikation in Kraft zu setzen.
Suchen Sie in den Warehouse-Veröffentlichungen die neueste Version der entsprechenden Binärdatei, z. Laden Sie die binäre Datei auf dem Server herunter und führen Sie sie aus:
wget https://github.com/yym68686/uni-api/releases/download/v0.0.99/uni-api-linux-x86_64-0.0.99.pex
chmod +x uni-api-linux-x86_64-0.0.99.pex
./uni-api-linux-x86_64-0.0.99.pex
Melden Sie sich zuerst im Panel an und klicken Sie in zusätzlichen Diensten auf die Registerkarte. Führen Sie Ihre eigenen Anwendungen aus, damit die Option Ihre eigenen Programme ausführen kann, und wenden Sie sich dann zum Panel -Portreservat, um einen Port zufällig zu öffnen.
Wenn Sie keinen eigenen Domain -Namen haben, wechseln Sie zu den Websites der WWW -Panel und löschen Sie den angegebenen Standarddomainnamen. Erstellen Sie dann eine neue Domain, wobei die Domäne die gerade gelöscht hat. Setzen Sie nach dem Klicken auf erweiterte Einstellungen den Website -Typ auf die Proxy -Domain, und der Proxy -Port sollte auf den gerade geöffneten Port verweisen. Wählen Sie nicht HTTPS verwenden.
SSH Melden Sie sich beim Serv00 -Server an und führen Sie den folgenden Befehl aus:
git clone --depth 1 -b main --quiet https://github.com/yym68686/uni-api.git
cd uni-api
python -m venv uni-api
tmux new -s uni-api
source uni-api/bin/activate
export CFLAGS= " -I/usr/local/include "
export CXXFLAGS= " -I/usr/local/include "
export CC=gcc
export CXX=g++
export MAX_CONCURRENCY=1
export CPUCOUNT=1
export MAKEFLAGS= " -j1 "
CMAKE_BUILD_PARALLEL_LEVEL=1 cpuset -l 0 pip install -vv -r requirements.txt
cpuset -l 0 pip install -r -vv requirements.txt
Strg+Bd, um TMUX zu beenden, warten Sie einige Stunden, bis die Installation abgeschlossen ist. Führen Sie nach Abschluss der Installation den folgenden Befehl aus:
tmux attach -t uni-api
source uni-api/bin/activate
export CONFIG_URL=http://file_url/api.yaml
export DISABLE_DATABASE=true
# Modify the port, xxx is the port, modify it yourself, corresponding to the port opened in the panel Port reservation
sed -i ' ' ' s/port=8000/port=xxx/ ' main.py
sed -i ' ' ' s/reload=True/reload=False/ ' main.py
python main.py
Verwenden Sie Strg+BD, um TMUX zu beenden, sodass das Programm im Hintergrund ausgeführt wird. Zu diesem Zeitpunkt können Sie Uni-API in anderen Chat-Clients verwenden. Curl -Testskript:
curl -X POST https://xxx.serv00.net/v1/chat/completions
-H ' Content-Type: application/json '
-H ' Authorization: Bearer sk-xxx '
-d ' {"model": "gpt-4o","messages": [{"role": "user","content": "Hello"}]} '
Referenzdokument:
https://docs.serv00.com/python/
https://linux.do/t/topic/201181
https://linux.do/t/topic/218738
Starten Sie den Behälter
docker run --user root -p 8001:8000 --name uni-api -dit
-e CONFIG_URL=http://file_url/api.yaml # If the local configuration file has already been mounted, there is no need to set CONFIG_URL
-v ./api.yaml:/home/api.yaml # If CONFIG_URL is already set, there is no need to mount the configuration file
-v ./uniapi_db:/home/data # If you do not want to save statistical data, there is no need to mount this folder
yym68686/uni-api:latest
Oder wenn Sie Docker Compose verwenden möchten, finden Sie hier ein Beispiel für Docker-compose.yml:
services :
uni-api :
container_name : uni-api
image : yym68686/uni-api:latest
environment :
- CONFIG_URL=http://file_url/api.yaml # If a local configuration file is already mounted, there is no need to set CONFIG_URL
ports :
- 8001:8000
volumes :
- ./api.yaml:/home/api.yaml # If CONFIG_URL is already set, there is no need to mount the configuration file
- ./uniapi_db:/home/data # If you do not want to save statistical data, there is no need to mount this folder
Config_url ist die URL der Remote -Konfigurationsdatei, die automatisch heruntergeladen werden kann. Wenn Sie beispielsweise die Konfigurationsdatei auf einer bestimmten Plattform nicht bequem ändern, können Sie die Konfigurationsdatei in einen Hosting-Dienst hochladen und einen direkten Link zu UNI-API zum Herunterladen angeben, dh der config_url. Wenn Sie eine lokal montierte Konfigurationsdatei verwenden, müssen config_url nicht festgelegt werden. Config_url wird verwendet, wenn es nicht bequem ist, die Konfigurationsdatei zu montieren.
Führen Sie den Docker -Komponieren -Container im Hintergrund aus
docker-compose pull
docker-compose up -d
Docker Build
docker build --no-cache -t uni-api:latest -f Dockerfile --platform linux/amd64 .
docker tag uni-api:latest yym68686/uni-api:latest
docker push yym68686/uni-api:latest
One-Click-Start-Docker-Bild neu starten
set -eu
docker pull yym68686/uni-api:latest
docker rm -f uni-api
docker run --user root -p 8001:8000 -dit --name uni-api
-e CONFIG_URL=http://file_url/api.yaml
-v ./api.yaml:/home/api.yaml
-v ./uniapi_db:/home/data
yym68686/uni-api:latest
docker logs -f uni-api
RESTFOR CULL -Test
curl -X POST http://127.0.0.1:8000/v1/chat/completions
-H " Content-Type: application/json "
-H " Authorization: Bearer ${API} "
-d ' {"model": "gpt-4o","messages": [{"role": "user", "content": "Hello"}],"stream": true} '
PEX Linux -Verpackung:
VERSION= $( cat VERSION )
pex -D . -r requirements.txt
-c uvicorn
--inject-args ' main:app --host 0.0.0.0 --port 8000 '
--platform linux_x86_64-cp-3.10.12-cp310
--interpreter-constraint ' ==3.10.* '
--no-strip-pex-env
-o uni-api-linux-x86_64- ${VERSION} .pex
MacOS -Verpackung:
VERSION= $( cat VERSION )
pex -r requirements.txt
-c uvicorn
--inject-args ' main:app --host 0.0.0.0 --port 8000 '
-o uni-api-macos-arm64- ${VERSION} .pex
Wir danken den folgenden Sponsoren für ihre Unterstützung:
Wenn Sie unser Projekt unterstützen möchten, können Sie uns auf folgende Weise sponsern:
Paypal
USDT-TRC20, USDT-TRC20 Wallet Adresse: TLFbqSv5pDu5he43mVmK1dNx7yBMFeN7d8
Alipay
Vielen Dank für Ihre Unterstützung!
Error processing request or performing moral check: 404: No matching model found
?Die Einstellung enable_moderation zu false behebt dieses Problem. Wenn enable_moderation true ist, muss die API das Modell mit Text-Moderation-latest verwenden können, und wenn Sie in den Einstellungen für Anbietermodell keine textherziger-leichte Bereitstellung bereitgestellt haben, tritt ein Fehler auf, der darauf hinweist, dass das Modell nicht gefunden werden kann.
Stellen Sie die Kanalreihenfolge direkt in den API_KEYS ein. Es sind keine anderen Einstellungen erforderlich. Beispielkonfigurationsdatei:
providers :
- provider : ai1
base_url : https://xxx/v1/chat/completions
api : sk-xxx
- provider : ai2
base_url : https://xxx/v1/chat/completions
api : sk-xxx
api_keys :
- api : sk-1234
model :
- ai2/*
- ai1/*
Fordern Sie auf diese Weise zuerst AI2 an und fordern Sie AI1 an, wenn es fehlschlägt.
Alle Planungsalgorithmen müssen aktiviert werden, indem API_KEYS (API).
Fixed_Priority: Prioritätsplanung festgelegt. Alle Anfragen werden immer vom Kanal des Modells ausgeführt, der zuerst eine Benutzeranforderung hat. Bei einem Fehler wechselt es zum nächsten Kanal. Dies ist der Standardplanungsalgorithmus.
Weighted_round_robin: Gewichtete Rund-Robin-Lastausgleich, fordert Kanäle mit dem angeforderten Modell des Benutzers gemäß dem in der Konfigurationsdatei api_keys festgelegten Gewichtsreihenfolge.
Lotterie: Rund-Robin-Lastausgleich zeichnen, den Kanal des Modells zufällig mit Benutzeranforderungen gemäß dem Gewicht in der Konfigurationsdatei API_KEYS (API).
Round_robin: Rund-Robin-Lastausgleich fordert den Kanal an, der das vom Benutzer angeforderte Modell gemäß der Konfigurationsreihenfolge in der Konfigurationsdatei api_keys (API) .Model besitzt. Sie können die vorherige Frage überprüfen, wie die Priorität von Kanälen festgelegt wird.
Mit Ausnahme einiger spezieller Kanäle, die in der erweiterten Konfiguration angezeigt werden, müssen alle OpenAI -Formatanbieter die base_url vollständig ausfüllen, was bedeutet, dass die Base_url mit/v1/chat/vollständigen Abschlüssen enden muss. Wenn Sie GitHub -Modelle verwenden, sollte die Base_url als https://models.inference.ai.azure.com/chat/completions, nicht die URL von Azure, ausgefüllt werden.
Die Timeout-Einstellung auf Kanalebene hat eine höhere Priorität als die globale Modell-Timeout-Einstellung. Die Prioritätsreihenfolge lautet: Modell-Timeout-Einstellung auf Kanalebene auf der Einstellung der Timeout-Einstellung auf Kanalebene> Global Model Timeout-Einstellung> Globale Standard-Timeout-Einstellung> Umgebungsvariable Timeout.
Durch Anpassung der Zeitlimitzeit für die Modell können Sie den Fehler einiger Kanäle ausführen. Wenn Sie auf den Fehler {'error': '500', 'details': 'fetch_response_stream Read Response Timeout'}
begegnen, versuchen Sie bitte, die Zeitlimitzeit für Modells zu erhöhen.
Wenn Sie die gleiche Frequenzgrenze für die vier Modelle Gemini-1.5-PRO-LATEST, Gemini-1.5-PRO, Gemini-1.5-PRO-001, Gemini-1.5-PRO-002 gleichzeitig festlegen möchten, können Sie es so festlegen:
api_key_rate_limit :
gemini-1.5-pro : 1000/min
Dadurch werden allen Modellen übereinstimmt, die die String von Gemini-1.5-PRO enthalten. Die Frequenzgrenze für diese vier Modelle, Gemini-1.5-PRO-LATEST, Gemini-1.5-PRO, Gemini-1.5-PRO-001, Gemini-1.5-PRO-002, werden alle auf 1000/min eingestellt. Die Logik für die Konfiguration des Felds api_key_rate_limit lautet wie folgt. Hier finden Sie eine Beispielkonfigurationsdatei:
api_key_rate_limit :
gemini-1.5-pro : 1000/min
gemini-1.5-pro-002 : 500/min
Zu diesem Zeitpunkt gibt es eine Anfrage, die das Modell Gemini-1.5-PRO-002 unter Verwendung des Modells gibt.
Zunächst wird der Uni-API versuchen, das Modell in der api_key_rate_limit präzise anzupassen. Wenn die Ratenlimit für Gemini-1.5-PRO-002 festgelegt ist, beträgt die Ratenlimit für Gemini-1,5-PRO-002 500/min. Wenn das angeforderte Modell zu diesem Zeitpunkt nicht Gemini-1.5-PRO-002 ist, sondern Gemini-1.5-PRO-Latest, da die API_Key_Rate_Limit kein Ratenlimit aufweist, das für Gemini-1.5-Pro-pro-latest für Gemini-1.5-Pro-lateste ein festgelegtes Ratengrenze ist, wird nach dem gleichen Präfix für Gimini. wird auf 1000/min eingestellt.