{
  "$schema": "https://json-schema.org/draft/2019-09/schema",
  "$id": "https://www.krakend.io/schema/v3.0/ai/providers.json",
  "title": "AI Providers",
  "description": "Declares once, at the service level, the AI providers the gateway can talk to. Each entry has a unique `name` that the backends reference, so you don't need to repeat the vendor settings on every backend.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/unified-llm-interface/",
  "type": "object",
  "required": [ "providers" ],
  "properties": {
    "providers": {
      "title": "Providers",
      "description": "The array of AI providers available for referencing from the backends. Each object is a different provider declaration.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/unified-llm-interface/",
      "type": "array",
      "items": {
        "type": "object",
        "allOf": [
          {
            "if": {
              "required": [ "provider" ],
              "properties": {
                "provider": {
                  "const": "anthropic"
                }
              }
            },
            "then": {
              "properties": {
                "endpoint": {
                  "default": "https://api.anthropic.com/v1/messages"
                },
                "model": {
                  "examples": [
                    "claude-haiku-4-5",
                    "claude-opus-4-1-20250805",
                    "claude-sonnet-4-20250514"
                  ],
                  "default": "claude-haiku-4-5"
                },
                "variables": {
                  "title": "Model Variables",
                  "description": "The variables specific to the Anthropic usage that are used to construct the payload.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/anthropic/",
                  "type": "object",
                  "properties": {
                    "extra_payload": {
                      "title": "Extra Payload",
                      "description": "A map of additional payload attributes you want to use in your custom `input_template` (this payload is not used in the default template). The attributes set here are accessible in your custom template as `{{ .variables.extra_payload.yourchosenkey }}`. This option helps adding rare customization and future attributes.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/anthropic/",
                      "type": "object"
                    },
                    "max_tokens": {
                      "title": "Max Tokens",
                      "description": "Maximum number of tokens that can be generated in the response. A token is approximately four characters. 100 tokens correspond to roughly 60-80 words.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/anthropic/",
                      "default": 1024,
                      "type": "integer"
                    },
                    "stop_sequences": {
                      "title": "Stop Sequences",
                      "description": "An array of sequences where the model will stop generating further tokens if found. This can be useful to control the length and content of the output.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/anthropic/",
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "temperature": {
                      "title": "Temperature",
                      "description": "The temperature is used for sampling during response generation, which occurs when topP and topK are applied. Temperature controls the degree of randomness in token selection. Lower temperatures are good for prompts that require a less open-ended or creative response, while higher temperatures can lead to more diverse or creative results.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/anthropic/",
                      "type": "number",
                      "maximum": 2,
                      "minimum": 0
                    },
                    "top_k": {
                      "title": "Top K",
                      "description": "Top-K changes how the model selects tokens for output. A top-K of 1 means the next selected token is the most probable among all tokens in the model's vocabulary (also called greedy decoding), while a top-K of 3 means that the next token is selected from among the three most probable tokens by using temperature.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/anthropic/",
                      "type": "integer"
                    },
                    "top_p": {
                      "title": "Top P",
                      "description": "Top-P changes how the model selects tokens for output. Tokens are selected from the most probable to least probable until the sum of their probabilities equals the top-P value. For example, if tokens A, B, and C have a probability of 0.3, 0.2, and 0.1 and the top-P value is 0.5, then the model will select either A or B as the next token by using temperature and excludes C as a candidate.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/anthropic/",
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          {
            "if": {
              "required": [ "provider" ],
              "properties": {
                "provider": {
                  "const": "bedrock"
                }
              }
            },
            "then": {
              "properties": {
                "endpoint": {
                  "default": "https://bedrock-runtime.eu-west-1.amazonaws.com/model/eu.amazon.nova-lite-v1:0/converse"
                },
                "model": {
                  "examples": [ "eu.amazon.nova-lite-v1:0" ],
                  "default": "eu.amazon.nova-lite-v1:0"
                },
                "variables": {
                  "title": "Model Variables",
                  "description": "The variables specific to the Bedrock usage that are used to construct the payload.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/bedrock/",
                  "type": "object",
                  "properties": {
                    "extra_payload": {
                      "title": "Extra Payload",
                      "description": "A map of additional payload attributes you want to use in your custom `input_template` (this payload is not used in the default template). The attributes set here are accessible in your custom template as `{{ .variables.extra_payload.yourchosenkey }}`. This option helps adding rare customization and future attributes.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/bedrock/",
                      "type": "object"
                    },
                    "max_tokens": {
                      "title": "Max Tokens",
                      "description": "An upper bound for the number of tokens that can be generated for a response, including visible output tokens and reasoning tokens.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/bedrock/",
                      "type": "integer"
                    },
                    "stop_sequences": {
                      "title": "Stop Sequences",
                      "description": "An array of sequences where the model will stop generating further tokens if found. This can be useful to control the length and content of the output.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/bedrock/",
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "temperature": {
                      "title": "Temperature",
                      "description": "What sampling temperature to use, recommended between 0.0 and 0.7. Higher values like 0.7 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. Change this or top_p but not both.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/bedrock/",
                      "type": "number",
                      "maximum": 2,
                      "minimum": 0
                    },
                    "top_k": {
                      "title": "Top K",
                      "description": "Top-K changes how the model selects tokens for output. A top-K of 1 means the next selected token is the most probable among all tokens in the model's vocabulary (also called greedy decoding), while a top-K of 3 means that the next token is selected from among the three most probable tokens by using temperature.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/bedrock/",
                      "type": "integer"
                    },
                    "top_p": {
                      "title": "Top P",
                      "description": "A float value between 0 and 1 that controls the nucleus sampling for text generation. It represents the cumulative probability threshold for token selection, where only the most probable tokens that add up to this threshold are considered. A higher value (closer to 1) allows for more diverse outputs, while a lower value (closer to 0) makes the output more focused and deterministic. Change this or temperature but not both.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/bedrock/",
                      "type": "number"
                    }
                  },
                  "patternProperties": {
                    "^[@$_#]": true
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          {
            "if": {
              "required": [ "provider" ],
              "properties": {
                "provider": {
                  "const": "gemini"
                }
              }
            },
            "then": {
              "properties": {
                "endpoint": {
                  "default": "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.5-flash:generateContent"
                },
                "model": {
                  "examples": [ "gemini-3.5-flash" ],
                  "default": "gemini-3.5-flash"
                },
                "variables": {
                  "title": "Model Variables",
                  "description": "The variables specific to the Google Gemini usage that are used to construct the payload.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/gemini/",
                  "type": "object",
                  "properties": {
                    "candidate_count": {
                      "title": "Candidate Count",
                      "description": "An integer value that specifies how many different completions (responses) the model should generate for a single input prompt. This can be useful for exploring multiple variations of the output.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/gemini/",
                      "default": 1,
                      "type": "integer"
                    },
                    "extra_payload": {
                      "title": "Extra Payload",
                      "description": "A map of additional payload attributes you want to use in your custom `input_template` (this payload is not used in the default template). The attributes set here are accessible in your custom template as `{{ .variables.extra_payload.yourchosenkey }}`. This option helps adding rare customization and future attributes.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/gemini/",
                      "type": "object"
                    },
                    "max_output_tokens": {
                      "title": "Max Tokens",
                      "description": "Maximum number of tokens that can be generated in the response. A token is approximately four characters. 100 tokens correspond to roughly 60-80 words.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/gemini/",
                      "type": "integer"
                    },
                    "stop_sequences": {
                      "title": "Stop Sequences",
                      "description": "An array of sequences where the model will stop generating further tokens if found. This can be useful to control the length and content of the output.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/gemini/",
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "temperature": {
                      "title": "Temperature",
                      "description": "The temperature is used for sampling during response generation, which occurs when topP and topK are applied. Temperature controls the degree of randomness in token selection. Lower temperatures are good for prompts that require a less open-ended or creative response, while higher temperatures can lead to more diverse or creative results.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/gemini/",
                      "type": "number",
                      "maximum": 2,
                      "minimum": 0
                    },
                    "top_k": {
                      "title": "Top K",
                      "description": "Top-K changes how the model selects tokens for output. A top-K of 1 means the next selected token is the most probable among all tokens in the model's vocabulary (also called greedy decoding), while a top-K of 3 means that the next token is selected from among the three most probable tokens by using temperature.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/gemini/",
                      "type": "integer"
                    },
                    "top_p": {
                      "title": "Top P",
                      "description": "Top-P changes how the model selects tokens for output. Tokens are selected from the most probable to least probable until the sum of their probabilities equals the top-P value. For example, if tokens A, B, and C have a probability of 0.3, 0.2, and 0.1 and the top-P value is 0.5, then the model will select either A or B as the next token by using temperature and excludes C as a candidate.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/gemini/",
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          {
            "if": {
              "required": [ "provider" ],
              "properties": {
                "provider": {
                  "const": "mistral"
                }
              }
            },
            "then": {
              "properties": {
                "endpoint": {
                  "default": "https://api.mistral.ai/v1/chat/completions"
                },
                "model": {
                  "examples": [ "mistral-small-latest", "codestral-latest" ],
                  "default": "mistral-small-latest"
                },
                "variables": {
                  "title": "Model Variables",
                  "description": "The variables specific to the Mistral usage that are used to construct the payload.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/mistral/",
                  "type": "object",
                  "properties": {
                    "extra_payload": {
                      "title": "Extra Payload",
                      "description": "A map of additional payload attributes you want to use in your custom `input_template` (this payload is not used in the default template). The attributes set here are accessible in your custom template as `{{ .variables.extra_payload.yourchosenkey }}`. This option helps adding rare customization and future attributes.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/mistral/",
                      "type": "object"
                    },
                    "max_tokens": {
                      "title": "Max Tokens",
                      "description": "An upper bound for the number of tokens that can be generated for a response, including visible output tokens and reasoning tokens.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/mistral/",
                      "type": "integer"
                    },
                    "n": {
                      "title": "Number of Completions",
                      "description": "An integer value that specifies how many different completions (responses) the model should generate for a single input prompt. This can be useful for exploring multiple variations of the output.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/mistral/",
                      "default": 1,
                      "type": "integer"
                    },
                    "random_seed": {
                      "title": "Random Seed",
                      "description": "An integer value to seed the random number generator used by the model. Setting a specific seed can help produce reproducible results across different requests.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/mistral/",
                      "type": "integer"
                    },
                    "safe_prompt": {
                      "title": "Safe Prompt",
                      "description": "A boolean flag to enable or disable Mistral's safe prompt feature, which helps filter out inappropriate or harmful content from the model's responses. By default, this feature is enabled to ensure safer interactions.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/mistral/",
                      "default": false,
                      "type": "boolean"
                    },
                    "stop": {
                      "title": "Stop Sequences",
                      "description": "An array of sequences where the model will stop generating further tokens if found. This can be useful to control the length and content of the output.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/mistral/",
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "temperature": {
                      "title": "Temperature",
                      "description": "What sampling temperature to use, recommended between 0.0 and 0.7. Higher values like 0.7 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. Change this or top_p but not both.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/mistral/",
                      "type": "number",
                      "maximum": 2,
                      "minimum": 0
                    },
                    "top_p": {
                      "title": "Top P",
                      "description": "A float value between 0 and 1 that controls the nucleus sampling for text generation. It represents the cumulative probability threshold for token selection, where only the most probable tokens that add up to this threshold are considered. A higher value (closer to 1) allows for more diverse outputs, while a lower value (closer to 0) makes the output more focused and deterministic. Change this or temperature but not both.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/mistral/",
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          {
            "if": {
              "required": [ "provider" ],
              "properties": {
                "provider": {
                  "const": "alibaba"
                }
              }
            },
            "then": {
              "properties": {
                "credentials": {
                  "examples": [ "sk-xxxx" ],
                  "@sensitive": 1
                },
                "endpoint": {
                  "default": "https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/responses"
                },
                "model": {
                  "examples": [ "qwen3.8-flash" ],
                  "default": "qwen3.8-flash"
                },
                "variables": {
                  "title": "Template Variables",
                  "description": "The variables specific to the Alibaba usage that are used to construct the payload.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/alibaba/",
                  "type": "object",
                  "properties": {
                    "extra_payload": {
                      "title": "Extra Payload",
                      "description": "A map of additional payload attributes you want to use in your custom `input_template` (this payload is not used in the default template). The attributes set here are accessible in your custom template as `{{ .variables.extra_payload.yourchosenkey }}`. This option helps adding rare customization and future attributes.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/alibaba/",
                      "type": "object"
                    },
                    "max_output_tokens": {
                      "title": "Max Output Tokens",
                      "description": "An upper bound for the number of tokens that can be generated for a response, including visible output tokens and reasoning tokens. Setting this value to `0` does not set any limit.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/alibaba/",
                      "type": "integer"
                    },
                    "temperature": {
                      "title": "Temperature",
                      "description": "What sampling temperature to use, between `0` and `2`. Higher values like `0.8` will make the output more random, while lower values like `0.2` will make it more focused and deterministic.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/alibaba/",
                      "type": "number",
                      "maximum": 2,
                      "minimum": 0
                    },
                    "top_p": {
                      "title": "Top P",
                      "description": "The nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/alibaba/",
                      "type": "number",
                      "maximum": 1,
                      "minimum": 0
                    },
                    "truncation": {
                      "title": "Truncation Strategy",
                      "description": "The strategy to use when truncating messages to fit within the model's context length (, the model will truncate the response to fit the context window by dropping items from the beginning of the conversation.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/alibaba/",
                      "default": "disabled",
                      "enum": [ "auto", "disabled" ]
                    }
                  }
                }
              }
            }
          }
        ],
        "if": {
          "required": [ "provider" ],
          "properties": {
            "provider": {
              "const": "openai"
            }
          }
        },
        "then": {
          "properties": {
            "credentials": {
              "examples": [ "sk-xxxx" ],
              "@sensitive": 1
            },
            "endpoint": {
              "default": "https://api.openai.com/v1/responses"
            },
            "model": {
              "examples": [ "gpt-5.4-mini", "gpt-5-nano", "gpt-4" ],
              "default": "gpt-5.4-mini"
            },
            "variables": {
              "title": "Template Variables",
              "description": "The variables specific to the OpenAI usage that are used to construct the payload.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/openai/",
              "type": "object",
              "properties": {
                "extra_payload": {
                  "title": "Extra Payload",
                  "description": "A map of additional payload attributes you want to use in your custom `input_template` (this payload is not used in the default template). The attributes set here are accessible in your custom template as `{{ .variables.extra_payload.yourchosenkey }}`. This option helps adding rare customization and future attributes.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/openai/",
                  "type": "object"
                },
                "max_output_tokens": {
                  "title": "Max Output Tokens",
                  "description": "An upper bound for the number of tokens that can be generated for a response, including visible output tokens and reasoning tokens. Setting this value to `0` does not set any limit.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/openai/",
                  "type": "integer"
                },
                "temperature": {
                  "title": "Temperature",
                  "description": "What sampling temperature to use, between `0` and `2`. Higher values like `0.8` will make the output more random, while lower values like `0.2` will make it more focused and deterministic.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/openai/",
                  "type": "number",
                  "maximum": 2,
                  "minimum": 0
                },
                "top_p": {
                  "title": "Top P",
                  "description": "The nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/openai/",
                  "type": "number",
                  "maximum": 1,
                  "minimum": 0
                },
                "truncation": {
                  "title": "Truncation Strategy",
                  "description": "The strategy to use when truncating messages to fit within the model's context length (, the model will truncate the response to fit the context window by dropping items from the beginning of the conversation.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/openai/",
                  "default": "disabled",
                  "enum": [ "auto", "disabled" ]
                }
              }
            }
          }
        },
        "required": [ "name", "provider" ],
        "properties": {
          "credentials": {
            "title": "Credentials",
            "description": "The API key used to authenticate against the provider. Inject it with an environment variable instead of writing it in the configuration.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/unified-llm-interface/",
            "type": "string",
            "@sensitive": 1
          },
          "debug": {
            "title": "Debug Mode",
            "description": "Enables the debug mode to log activity for troubleshooting. Do not set this value to `true` in production as it may log sensitive data.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/unified-llm-interface/",
            "default": false,
            "type": "boolean"
          },
          "endpoint": {
            "title": "Endpoint",
            "description": "Overrides the default API endpoint of the provider. Set it when you need to reach a proxy, a private deployment, or a region-specific host instead of the vendor's public API. When you don't set it, each provider uses its own default endpoint. Gemini and Bedrock build theirs from the `model` and `streaming` values, so their default shown here corresponds to the default `model` without streaming.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/unified-llm-interface/",
            "type": "string",
            "@sensitive": 3
          },
          "input_template": {
            "title": "Input Template",
            "description": "A path to a custom [Go template](https://pkg.go.dev/text/template) that sets the payload format sent to the provider. You don't need to set this value unless you want to override the default template making use of all the `variables` listed in this configuration.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/unified-llm-interface/",
            "type": "string"
          },
          "model": {
            "title": "Model Name",
            "description": "The name of the model you want to use. The value you provide is passed as is to the provider and KrakenD does not check if the model is currently accepted by the vendor. Check the available models on the vendor documentation. When you don't set it, each provider uses its own default model.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/unified-llm-interface/",
            "type": "string"
          },
          "name": {
            "title": "Provider Name",
            "description": "A unique name for this provider declaration. This is the name you use to reference the provider from the backends, so you declare its settings once and reuse them everywhere.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/unified-llm-interface/",
            "examples": [ "fast-chat" ],
            "type": "string",
            "minLength": 1
          },
          "output_template": {
            "title": "Output Template",
            "description": "A path to a custom [Go template](https://pkg.go.dev/text/template) that sets how the response from the provider is transformed before being sent to the client. The default template extracts the text from the first choice returned by the provider so in most cases you don't need to set a custom output template.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/unified-llm-interface/",
            "type": "string"
          },
          "provider": {
            "title": "Provider",
            "description": "The AI vendor this declaration connects to. The chosen vendor determines which `variables` are accepted.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/unified-llm-interface/",
            "enum": [
              "anthropic",
              "bedrock",
              "gemini",
              "mistral",
              "openai",
              "alibaba"
            ]
          },
          "streaming": {
            "title": "Streaming",
            "description": "Enables streaming responses, so the tokens generated by the model are forwarded to the client as they are produced instead of waiting for the complete response.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/unified-llm-interface/",
            "default": false,
            "type": "boolean"
          },
          "format": {
            "title": "Stream format",
            "description": "Wire format KrakenD exposes to the client for streaming responses, when not defined, the request and response format is not modified. Only anthropic and openai stream formats are supported client-side, regardless of the upstream connector. When defined, KrakenD translates the client's request into the upstream connector's format, and translates the streamed response back into this format before returning it.",
            "enum": [ "anthropic", "openai" ]
          },
          "variables": {
            "title": "Template Variables",
            "description": "The variables KrakenD uses to build the payload for the chosen `provider`.\n\nSee: https://www.krakend.io/docs/enterprise/ai-gateway/unified-llm-interface/",
            "type": "object"
          }
        },
        "patternProperties": {
          "^[@$_#]": true
        },
        "additionalProperties": false
      }
    }
  },
  "patternProperties": {
    "^[@$_#]": true
  },
  "additionalProperties": false
}
