Skip to main content

Overview

Chunkr supports any OpenAI-compatible API for LLM processing. You can configure multiple models with different providers, set rate limits, and specify default and fallback models.

Configuration File

LLM models are configured in a models.yaml file. Copy models.example.yaml to get started:
Set the path to your models configuration file using the environment variable:

Model Configuration Structure

Each model in the configuration requires:
string
required
Unique identifier for the model. Use this ID in POST and PATCH requests to reference the model.
string
required
The model name/identifier used by the provider (e.g., gpt-4o, gemini-2.0-flash-lite).
string
required
The API endpoint URL for the provider’s chat completions service.
string
required
Your API key for authentication with the provider.
boolean
Mark one model as the default. This model is used when no specific model is requested.
boolean
Mark one model as the fallback. Used when FallbackStrategy::Default is configured.
integer
Optional rate limit in requests per minute for this model.
You must configure exactly one default model and one fallback model (they can be the same model).

Provider Examples

models.yaml
Rate limits help prevent API quota exhaustion. OpenAI has different rate limits based on your tier.

Complete Example

Here’s a complete models.yaml with multiple providers:
models.yaml

Using Models in Requests

Specifying a Model

Reference your configured model by its id in the llm_processing configuration:

Default Model

If you don’t specify a model_id, the model marked with default: true is used automatically:

Fallback Strategy

Configure how Chunkr handles LLM failures:
enum
default:"Default"
  • None: No fallback, task fails on LLM error
  • Default: Use the model marked with fallback: true
  • Model("model-id"): Use a specific model as fallback

Rate Limiting

Rate limits prevent exceeding provider quotas:
Chunkr automatically queues requests when approaching the limit.

Best Practices

Never commit API keys to version control. Use environment variables or secure secret management.
  1. Use different models for different purposes
    • Fast model (e.g., GPT-4o-mini, Gemini Flash) for simple segments
    • High-quality model (e.g., GPT-4o) for complex tables and formulas
  2. Configure appropriate rate limits
    • Check your provider’s rate limits
    • Set conservative limits to avoid throttling
  3. Always configure a fallback
    • Ensures processing continues if primary model fails
    • Use a reliable, fast model as fallback
  4. Test your configuration

Troubleshooting

Model Not Found

If you get a “model not found” error:
  1. Verify the model id exists in your models.yaml
  2. Check that LLM__MODELS_PATH points to the correct file
  3. Restart the Chunkr service after updating models.yaml

Authentication Errors

  1. Verify your API key is correct and not expired
  2. Check that the API key has the necessary permissions
  3. For self-hosted models, verify the endpoint is accessible

Rate Limit Errors

  1. Lower the rate-limit value in your configuration
  2. Upgrade your provider tier for higher limits
  3. Configure a fallback model with higher limits