openai.ex icon indicating copy to clipboard operation
openai.ex copied to clipboard

Can pass custom headers to config. Allow using alternative endpoints configuration

Open julienmarie opened this issue 1 year ago • 1 comments

I needed to modify the code to be able to use OpenRouter ( and access GPT 4 32k ). We can now use custom_headers in the config to add custom headers this way:

config :openai,                                                                                               
   api_key: "...", 
   organization_key: "...",                                                     
   http_options: [...],                                                                
   api_url: "https://openrouter.ai/api",                                                                 
   custom_headers: [                                                                                     
       {"HTTP-Referer", "https://example.com/"},                                                      
       {"X-Title", "MyService" }                                                                           
   ]

Note: this is my first open source contribution ever. Not sure I'm following the proper etiquette and process.

julienmarie avatar Sep 15 '23 00:09 julienmarie

Hi, sorry for the super late response, but I'm prioritising other projects at the moment. I will try to check the PR in the following days, and align it to the current state of main

mgallo avatar Nov 17 '23 17:11 mgallo