Open sbe-arg opened 3 months ago
For me, the following setting works. Set the API_KEY
environment, when you have multiple api keys just seperate it with commas, like below :
...
env:
- name: DEBUG
value: "true"
- name: API_KEY
value: "aaa,bbb"
...
Then send request with Authorization http header, value start with Bearer
prefix :
curl --location 'http://localhost:8080/v1/chat/completions' \
--header 'Authorization: Bearer aaa' \
--header 'Content-Type: application/json' \
--data '{
"model": "phi-2",
"messages": [{"role": "user", "content": "how are you?"}],
"temperature": 0.3
}'
I found it in the source code, not document.
I see that you're having trouble setting and using the API_KEY
for Nextcloud or HTTP/curl commands in the LocalAI docker-compose setup. As mentioned by @sbe-arg, you can set multiple API keys by separating them with commas in the API_KEY
environment variable. Here's an example from their docker-compose file:
...
env:
- name: DEBUG
value: "true"
- name: API_KEY
value: "aaa,bbb"
...
To send a request with the Authorization header, you must start the value with the Bearer
prefix. Here's an example using curl:
curl --location 'http://localhost:8080/v1/chat/completions' \
--header 'Authorization: Bearer aaa' \
--header 'Content-Type: application/json' \
--data '{"model": "phi-2",
"messages": [{"role": "user", "content": "how are you?"}],
"temperature": 0.3
}'
Regarding the documentation, I understand that you found the information in the source code and not in the official documentation. This is an experiment, and the documentation might not cover all the details yet. You can find more information about this feature in the LocalAI source code ( https://github.com/mudler/LocalAI/blob/main/docs/content/docs/features/openai-functions.md ).
(I am a bot, an experiment of @mudler, and I audited this issue from the LocalAI Github project.)
Can I add something like api_keys.json and make local-ai check this file for the keys?
related #2046
I cannot figure out how to set and use API_KEY for nextcloud or http/curl commands
I tried adding the environment var API_KEY='some-value-crypt' in my docker compose
They using it to authenticate in the nextcloud API settings but the same api_key value does not work either on the http enpoint via curl
Does it need any specif requirements or encryption?
or it needs something on the lines of '["key1","key2"]' or '["{key1"},"{key2}"}' nothing I tried works.