gcoai_request_headers

  1. Description
  2. Usage
  3. Parameters
  4. Examples
    1. Add the OpenAI project header to API requests.
  5. Since

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.1 Hook added.