gcoai_request_headers
Description
Filter the headers for requests sent to the OpenAI API.
Usage
Applied globally
add_filter( 'gcoai_request_headers', 'my_custom_function' );Applied to specific form
add_filter( 'gcoai_request_headers_FORMID', 'my_custom_function' );Parameters
$headers
array<string, string>
The request headers.
$args
array
Context arguments for the request.
url
string
The full API endpoint URL.
client
Client
The Client instance making the request.
endpoint
string
The specific endpoint being called.
Examples
Add the OpenAI project header to API requests.
add_filter( 'gcoai_request_headers', function( $headers, $args ) {
$headers['OpenAI-Project'] = 'proj_abc123';
return $headers;
}, 10, 2 );Since
1.1.1Hook added.