Coder Social home page Coder Social logo

document use of api_key / API_KEY about localai HOT 4 OPEN

sbe-arg avatar sbe-arg commented on May 29, 2024
document use of api_key / API_KEY

from localai.

Comments (4)

chenxinlong avatar chenxinlong commented on May 29, 2024 2

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.

from localai.

localai-bot avatar localai-bot commented on May 29, 2024 1

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.)

from localai.

JackBekket avatar JackBekket commented on May 29, 2024

Can I add something like api_keys.json and make local-ai check this file for the keys?

from localai.

jtwolfe avatar jtwolfe commented on May 29, 2024

related #2046

from localai.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.