Skip to content

Commit df15041

Browse files
committed
Add support for openai org headers
1 parent 8753c5c commit df15041

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

.env-example

+1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ API_BASE=https://api.openweathermap.org
33
# API_BASE=https://api.unsplash.com
44
API_AUTH_TYPE=query
55
API_AUTH_KEY=appid
6+
OPEN_AI_ORG=org_1234567
67
PORT=3344
78
DOCS_URL=https://openweathermap.org/api

readme.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
# Getting Started
22

3-
This project was bootstrapped with [imba-base-template](https://github.com/imba/imba-base-template).
4-
5-
It aims to be a generic proxy for api´s where you can inject api keys / authentication without exposing it to the requester. It uses dotenv to define it´s workings.
3+
This repo aims to be a generic proxy for api´s where you can inject api keys / authentication without exposing it to the requester. It uses dotenv to define it´s workings.
64

75
1. Copy .env-example to .env and set the env vars to fit the api of choice
86

97
`API_BASE`: The root url to proxy - for example `https://api.openweathermap.org`
108
`API_KEYS`: A comma separated list of api keys.
119
`API_AUTH_TYPE`: `query` / `bearer` / `header`
1210
`API_AUTH_KEY`: `appid`, `client_id`
11+
`OPEN_AI_ORG`: The organization ID for your account in openAI
1312
`PORT`: 3000
1413

1514
2. Copy example-pm2.json to pm2.json and set the fields to the values of choice.

server.imba

+4-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ app.all(/.*/) do(req,res)
5959

6060
if process.env.API_AUTH_TYPE == 'bearer'
6161
headers.authorization = "Bearer {pick-key!}";
62-
62+
63+
if process.env.OPEN_AI_ORG # Should handle any extra header at some point.
64+
headers['OpenAI-Organization'] = process.env.OPEN_AI_ORG
65+
6366
let payload = await node-fetch(url,
6467
method: req.method
6568
body: ['POST', 'PUT'].includes(req.method) ? body : undefined

0 commit comments

Comments
 (0)