Disclosure: I run APIVAI, the gateway used in the examples below. The setup is the same for any endpoint that speaks the OpenAI or Anthropic format.
Dify is an open-source platform for building LLM apps: chatbots, agents, workflows and knowledge-base (RAG) apps. It reaches models through model provider plugins, and with a third-party gateway there are enough fields that it's easy to fill one in wrong. This post goes through the actual fields of Dify's official openai_api_compatible plugin (version 0.0.68) and the anthropic plugin.
| Plugin | Address field | Models | Best for |
|---|---|---|---|
| OpenAI-API-compatible | API Base URL: https://api.apivai.com/v1 |
Claude and GPT | One provider for every model; you type the model IDs |
| Anthropic | API URL: https://api.apivai.com |
Claude only | Claude only, in the native format with prompt caching |
Start with OpenAI-API-compatible: you type each model ID yourself, so a new model works as soon as the gateway lists it.
Providers live on the Model Provider page: under Integrations in current Dify Cloud, under Settings in the account menu in older self-hosted versions. Each provider applies to the whole workspace, and only owners and admins can change it.
Open Model Provider, find OpenAI-API-compatible in the list of providers you can install (or on the Dify Marketplace) and click Install.
On the OpenAI-API-compatible card, click Add Model and fill in:
| Field | Value |
|---|---|
| Model Type | LLM |
| Model Name | claude-sonnet-4-6 (the exact model ID) |
| Model display name | optional, e.g. "Claude Sonnet 4.6" |
| API Key | your key |
| API Base URL | https://api.apivai.com/v1 |
| model name for API endpoint | leave empty |
| Completion mode | Chat |
| Model context size | no larger than the model's context window |
| Upper bound for max tokens | 8192 or more |
| Function Call Type | Tool Call |
| Stream function calling | Support |
| API Type | Chat Completions API (/chat/completions) |
Leave the rest at their defaults. Older versions of the plugin call the address field API endpoint URL; the value is the same.
The fields people most often misread:
When you click Save, Dify sends a test request and only saves if it passes. Repeat Add Model for each model you want, with the same key and address, for example gpt-5.5 and claude-haiku-4-5.
Take model IDs from the API:
curl https://api.apivai.com/v1/models -H "Authorization: Bearer your-key"
https://api.apivai.com. Do /v1; the plugin's Anthropic client appends /v1/messages itself. Leave claude-sonnet-4-6); others have different or dated names. If a model is missing or returns "model not found", click claude-haiku-4-5 or gpt-6-luna
claude-sonnet-5-5
claude-opus-5-5
A routing workflow (a cheap model classifies first, then hands the hard cases to a strong one) is the most common way to keep Dify costs down.
https://api.apivai.com/v1, without /chat/completions; the Anthropic plugin needs At the time of writing, most Claude models on APIVAI are 56–58% below Anthropic's list prices and GPT models up to 86% below OpenAI's; for example, Claude Sonnet 4.6 is $1.26 / $6.32 per million input / output tokens against the official $3 / $15. It's prepaid and billed per token, with no subscription. The full table is at https://apivai.com/pricing.
Questions are welcome in the comments.