Created
December 23, 2023 19:40
-
-
Save sudoaza/acdffd014e0892bf9e952e540a681201 to your computer and use it in GitHub Desktop.
Keep openai api key safe while sharing access
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global | |
log stdout format raw local0 | |
maxconn 2000 | |
defaults | |
log global | |
mode http | |
option httplog | |
timeout connect 5000ms | |
timeout client 50000ms | |
timeout server 50000ms | |
frontend openai_proxy | |
bind *:8000 | |
default_backend openai_api | |
backend openai_api | |
http-request set-header Authorization "Bearer %[env(OPENAI_API_KEY)]" | |
server openai api.openai.com:443 ssl verify required ca-file /etc/ssl/certs/ca-certificates.crt | |
# docker run --rm -p 8000:8000 -e OPENAI_API_KEY=sk-1234 -v $(pwd):/usr/local/etc/haproxy/ haproxy | |
# openai.api_base = 'http://localhost:8000' # In python script |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment