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 headers in AsyncWebsocket #50

Merged
merged 1 commit into from
Oct 8, 2024

Conversation

p-i-
Copy link
Contributor

@p-i- p-i- commented Oct 8, 2024

I've updated Gin AsyncWebsocket to support custom headers when creating a websocket connection, so I can now replicate what I was doing in Python, i.e.:

ws = create_connection(
    WS_URL,
    header=[
        f'Authorization: Bearer {API_KEY}',
        'OpenAI-Beta: realtime=v1'
    ]
)

In C++:

    juce::String apiKey = "...";
    
    juce::URL openAIURL("wss://api.openai.com/v1/realtime?model=gpt-4o-realtime-preview-2024-10-01");

    juce::StringPairArray customHeaders;
    customHeaders.set("Authorization", "Bearer " + apiKey);
    customHeaders.set("OpenAI-Beta", "realtime=v1");

    websocket = std::make_unique<gin::AsyncWebsocket>(openAIURL, customHeaders);

@FigBug FigBug merged commit 2cfb33e into FigBug:master Oct 8, 2024
2 of 3 checks passed
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.

2 participants