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

Add support for custom HTTP headers #91

Closed
benvolioT opened this issue Jul 21, 2023 · 2 comments
Closed

Add support for custom HTTP headers #91

benvolioT opened this issue Jul 21, 2023 · 2 comments

Comments

@benvolioT
Copy link

benvolioT commented Jul 21, 2023

Is your feature request related to a problem? Please describe.
I would like to integrate with OpenAI via the Helicone proxy, but to do so, I need to be able to specify a custom HTTP header.

Describe the solution you'd like
Proxy APIs like Helicone wrap OpenAI's APIs with additional functionality. To use Helicone, you not only need to point the OpenAI client at the Helicone host, but you also have to set an additional HTTP header on the requests. For details, please refer to https://docs.helicone.ai/getting-started/integration-method/openai-proxy.

To enable this, I propose:

  1. Changing OpenAI.swift's Configuration struct to take an optional dictionary of key/value pairs, where the key is the name of the HTTP header, and the value is its value.
  2. Modifying performRequest() and performSteamingRequest() in that file to pass that optional dictionary to URLRequestBuildable.build() in a similar manner as organizationIdentifier is passed today
  3. Changing the URLRequestBuildable.build() interface to accept that optional dictionary
  4. Changing JSONRequest.build(), MultipartFormDataRequest.build(), etc. to conform to the updated interface, setting the header(s) on the request that is built if any were supplied in the optional dictionary.

Describe alternatives you've considered
I think taking an optional dictionary of headers is preferable to explicitly covering every possible header that might be used by other proxies like Helicone. Other than that, I can't think of too many other ways to do this.

Additional context
N/A

@benvolioT
Copy link
Author

Submitted pull request #93 for this issue.

@nezhyborets
Copy link
Collaborator

Released in 0.3.4

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

No branches or pull requests

2 participants