Skip to main content
Create a configuration object for customizing OpenAI API client behavior. Use this to set base URLs, timeouts, organization IDs, and other advanced client options.

Samples

Configure timeout

Set a custom timeout for API requests:
SELECT ai.openai_client_config(
    timeout_seconds => 60
);

Use custom base URL

Point to a different OpenAI-compatible API endpoint:
SELECT ai.openai_client_config(
    base_url => 'https://api.custom-endpoint.com/v1'
);

Full configuration

Combine multiple settings:
SELECT ai.openai_embed(
    'text-embedding-ada-002',
    'sample text',
    client_config => ai.openai_client_config(
        base_url => 'https://custom.openai.com/v1',
        timeout_seconds => 120,
        max_retries => 3
    )
);

Arguments

NameTypeDefaultRequiredDescription
base_urlTEXTNULLCustom base URL for the OpenAI API
timeout_secondsFLOAT8NULLTimeout in seconds for API requests
organizationTEXTNULLOpenAI organization ID
projectTEXTNULLOpenAI project ID
max_retriesINTNULLMaximum number of retry attempts
default_headersJSONBNULLDefault headers to include in all requests
default_queryJSONBNULLDefault query parameters for all requests

Returns

JSONB: A configuration object that can be passed to other OpenAI functions via the client_config parameter.