Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/dais-polymtl/flock/llms.txt

Use this file to discover all available pages before exploring further.

Flock supports OpenAI as a first-class provider. Once you store your API key with CREATE SECRET, every Flock function — llm_complete, llm_filter, llm_embedding, and the rest — can use any OpenAI model. Flock also supports any OpenAI-compatible API (such as Groq or a self-hosted vLLM server) by supplying a custom BASE_URL.

Prerequisites

You need an OpenAI API key. Create one at platform.openai.com/api-keys. Make sure Flock is installed and loaded before continuing — see the Quickstart if you haven’t done that yet.

Configure your secret

Store your API key using DuckDB’s CREATE SECRET command with the openai type:
CREATE SECRET (
    TYPE openai,
    API_KEY 'your-api-key'
);
The API_KEY field is required. Flock will raise an error if it is missing or empty.
DuckDB’s secret manager redacts api_key values in all output — you can safely inspect secrets with FROM duckdb_secrets() without exposing your key.

Create a model

Register a named model that references the provider and model ID you want to use:
CREATE MODEL(
    'QuackingModel',
    'gpt-4o',
    'openai',
    {"tuple_format": "json", "batch_size": 32, "model_parameters": {"temperature": 0.7}}
);
The four arguments are:
ArgumentDescription
'QuackingModel'Unique name you reference in queries
'gpt-4o'OpenAI model ID
'openai'Provider name
{...}Config: batch size, tuple format, and model parameters

Run a query

With your secret and model in place, call llm_complete:
SELECT llm_complete(
    {'model_name': 'QuackingModel'},
    {'prompt': 'Write a short poem about a database.'}
);
To incorporate table columns as context:
SELECT llm_complete(
    {'model_name': 'QuackingModel'},
    {
        'prompt': 'Classify the sentiment of this review: {review}',
        'context_columns': [{'data': review_text, 'name': 'review'}]
    }
) AS sentiment
FROM customer_reviews;

Available OpenAI models

The table below lists commonly used models. For the full and up-to-date list, see the OpenAI models documentation.
Model IDTypeNotes
gpt-4oChat completionBest overall performance
gpt-4o-miniChat completionFast and cost-effective
gpt-4-turboChat completionPrevious flagship model
text-embedding-3-smallEmbeddingRecommended for most embedding tasks
text-embedding-3-largeEmbeddingHigher-dimensional embeddings
text-embedding-ada-002EmbeddingLegacy embedding model
Use embedding models with llm_embedding and chat models with llm_complete, llm_filter, and aggregate functions.

OpenAI-compatible providers

Any provider with an OpenAI-compatible API works with the openai secret type — just add a BASE_URL. The example below configures Groq:
CREATE SECRET (
    TYPE openai,
    BASE_URL 'https://api.groq.com/openai/v1/',
    API_KEY 'your-groq-api-key'
);
Then create a model using the provider’s model ID:
CREATE MODEL(
    'GroqModel',
    'llama3-8b-8192',
    'openai',
    {"tuple_format": "json", "batch_size": 32}
);
The rest of the workflow is identical to native OpenAI.

Next steps

Structured output

Enforce JSON schemas on llm_complete responses

Scalar functions

Full reference for llm_complete, llm_filter, llm_embedding, and more

Build docs developers (and LLMs) love