Skip to content

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

Open
julienmarie wants to merge 2 commits into
mgallo:mainfrom
julienmarie:main
Open

Can pass custom headers to config. Allow using alternative endpoints configuration#53
julienmarie wants to merge 2 commits into
mgallo:mainfrom
julienmarie:main

Conversation

@julienmarie

Copy link
Copy Markdown

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.

Comment thread lib/openai/client.ex
end

def api_post(url, params \\ [], config) do
IO.inspect config, label: "API_POST_CONFIG"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably remove this inspect

@mgallo

mgallo commented Nov 17, 2023

Copy link
Copy Markdown
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants