Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

julienmarie
Copy link

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.

@@ -79,6 +85,16 @@ defmodule OpenAI.Client do
end

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

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
Copy link
Owner

mgallo commented Nov 17, 2023

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