Skip to main content
Retrieve a list of all models available from OpenAI, including their creation dates and ownership information. This is useful for discovering available models and verifying access to specific models.

Samples

List all models

Get all available OpenAI models:
SELECT *
FROM ai.openai_list_models()
ORDER BY created DESC;
Returns:
           id              |        created         |    owned_by
---------------------------+------------------------+-----------------
 gpt-4o                    | 2024-05-10 13:50:49-05 | system
 gpt-4o-mini               | 2024-07-17 09:33:20-05 | system
 gpt-4-turbo               | 2024-04-05 18:57:21-05 | system
 text-embedding-ada-002    | 2022-12-16 12:48:49-06 | openai-internal
 ...

Find specific models

Search for models matching a pattern:
SELECT *
FROM ai.openai_list_models()
WHERE id LIKE '%gpt-4o%'
ORDER BY created DESC;

Check model availability

Verify a specific model is available:
SELECT EXISTS (
    SELECT 1
    FROM ai.openai_list_models()
    WHERE id = 'gpt-4o-mini'
) AS model_available;

Arguments

NameTypeDefaultRequiredDescription
api_keyTEXTNULLOpenAI API key. If not provided, uses ai.openai_api_key setting
api_key_nameTEXTNULLName of the secret containing the API key
extra_headersJSONBNULLAdditional HTTP headers to include in the API request
extra_queryJSONBNULLAdditional query parameters for the API request
verboseBOOLEANFALSEEnable verbose logging for debugging
client_configJSONBNULLAdvanced client configuration options

Returns

TABLE(id TEXT, created TIMESTAMPTZ, owned_by TEXT): A table with one row per model containing:
  • id: The model identifier (e.g., gpt-4o-mini)
  • created: When the model was created
  • owned_by: The organization that owns the model