{
  "openapi": "3.1.0",
  "info": {
    "title": "API Tukai compatible OpenAI et Anthropic",
    "version": "1.0.0",
    "description": "Sous-ensemble public du contrat de l'API Tukai : les opérations accessibles avec une clé tuk_sk_ et le catalogue public. Documentation : https://developers.tuk-ai.com/docs."
  },
  "servers": [
    {
      "url": "https://chat.tuk-ai.com"
    }
  ],
  "paths": {
    "/v1/chat/completions": {
      "post": {
        "description": "Voir https://developers.tuk-ai.com/docs/compatibility",
        "operationId": "CompatController_chatCompletions",
        "parameters": [
          {
            "description": "A Tukai API key, `tuk_sk_…`, created at POST /v1/api-keys or by `tukai login`.",
            "in": "header",
            "name": "Authorization",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OpenAiChatRequestDto"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAiChatCompletionDto"
                }
              }
            },
            "description": "`stream:false` — one `chat.completion` object."
          },
          "400": {
            "description": "OpenAI-shaped `invalid_request_error`."
          },
          "401": {
            "description": "OpenAI-shaped."
          },
          "402": {
            "description": "OpenAI-shaped `insufficient_quota`."
          },
          "403": {
            "description": "OpenAI-shaped `permission_error`."
          },
          "404": {
            "description": "OpenAI-shaped `not_found_error`."
          },
          "422": {
            "description": "OpenAI-shaped `invalid_request_error`."
          },
          "429": {
            "description": "OpenAI-shaped `rate_limit_error`."
          },
          "502": {
            "description": "OpenAI-shaped `server_error`."
          },
          "503": {
            "description": "OpenAI-shaped `server_error`."
          }
        },
        "security": [
          {
            "cleTukai": []
          },
          {
            "cleTukaiEnTete": []
          }
        ],
        "summary": "OpenAI's chat completions, served by Tukai. Unmodified SDKs work.",
        "tags": [
          "compat"
        ]
      }
    },
    "/v1/messages": {
      "post": {
        "description": "Voir https://developers.tuk-ai.com/docs/compatibility",
        "operationId": "CompatController_messages",
        "parameters": [
          {
            "description": "Accepted and interpreted by this gateway.",
            "in": "header",
            "name": "anthropic-version",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "A Tukai API key, `tuk_sk_…`, created at POST /v1/api-keys or by `tukai login`.",
            "in": "header",
            "name": "x-api-key",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnthropicMessagesRequestDto"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnthropicMessageResponseDto"
                }
              }
            },
            "description": "`stream:false` — one `message` object."
          },
          "401": {
            "description": "Anthropic-shaped."
          },
          "402": {
            "description": "Anthropic-shaped `billing_error`."
          },
          "403": {
            "description": "Anthropic-shaped `permission_error`."
          },
          "404": {
            "description": "Anthropic-shaped `not_found_error`."
          },
          "413": {
            "description": "Anthropic-shaped `request_too_large`."
          },
          "422": {
            "description": "Anthropic-shaped `invalid_request_error`."
          },
          "429": {
            "description": "Anthropic-shaped `rate_limit_error`."
          },
          "503": {
            "description": "Anthropic-shaped `api_error`."
          },
          "529": {
            "description": "Anthropic-shaped `overloaded_error`."
          }
        },
        "security": [
          {
            "cleTukai": []
          },
          {
            "cleTukaiEnTete": []
          }
        ],
        "summary": "Anthropic's messages, served by Tukai — on ANY provider in the registry.",
        "tags": [
          "compat"
        ]
      }
    },
    "/v1/messages/count_tokens": {
      "post": {
        "description": "Voir https://developers.tuk-ai.com/docs/compatibility",
        "operationId": "CompatController_countTokens",
        "parameters": [
          {
            "description": "A Tukai API key, `tuk_sk_…`, created at POST /v1/api-keys or by `tukai login`.",
            "in": "header",
            "name": "x-api-key",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnthropicCountTokensRequestDto"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnthropicCountTokensResultDto"
                }
              }
            },
            "description": ""
          },
          "401": {
            "description": "Anthropic-shaped `authentication_error`."
          },
          "403": {
            "description": "Anthropic-shaped `permission_error`."
          },
          "404": {
            "description": "Anthropic-shaped `not_found_error`."
          },
          "422": {
            "description": "Anthropic-shaped `invalid_request_error`."
          },
          "429": {
            "description": "Anthropic-shaped `rate_limit_error`."
          }
        },
        "security": [
          {
            "cleTukai": []
          },
          {
            "cleTukaiEnTete": []
          }
        ],
        "summary": "How many input tokens is this? — locally, cheaply, before anything is spent.",
        "tags": [
          "compat"
        ]
      }
    },
    "/v1/models": {
      "get": {
        "description": "Voir https://developers.tuk-ai.com/docs/compatibility",
        "operationId": "ModelsController_list",
        "parameters": [
          {
            "description": "The ETag of a previously received catalogue.",
            "in": "header",
            "name": "If-None-Match",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelCatalogueDto"
                }
              }
            },
            "description": ""
          },
          "304": {
            "description": "The catalogue has not changed for this caller (ETag match)."
          },
          "429": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetailsDto"
                }
              }
            },
            "description": "Throttled per IP (RATE_LIMIT_IP, details.retry_after_ms)"
          },
          "503": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetailsDto"
                }
              }
            },
            "description": "The catalogue could not be read (SYS_SERVICE_UNAVAILABLE)."
          }
        },
        "security": [],
        "summary": "The model catalogue: capabilities, availability for the caller's plan, and the per-surface defaults",
        "tags": [
          "models"
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "ProblemDetailsDto": {
        "properties": {
          "code": {
            "type": "string"
          },
          "detail": {
            "type": "string"
          },
          "details": {
            "additionalProperties": {},
            "propertyNames": {
              "type": "string"
            },
            "type": "object"
          },
          "errors": {
            "items": {
              "properties": {
                "code": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                },
                "path": {
                  "type": "string"
                }
              },
              "required": [
                "path",
                "code",
                "message"
              ],
              "type": "object"
            },
            "type": "array"
          },
          "instance": {
            "type": "string"
          },
          "status": {
            "maximum": 9007199254740991,
            "minimum": -9007199254740991,
            "type": "integer"
          },
          "title": {
            "type": "string"
          },
          "traceId": {
            "type": "string"
          },
          "type": {
            "type": "string"
          }
        },
        "required": [
          "type",
          "title",
          "status",
          "instance",
          "traceId",
          "code"
        ],
        "type": "object"
      },
      "ModelCatalogueDto": {
        "additionalProperties": false,
        "properties": {
          "data": {
            "items": {
              "additionalProperties": false,
              "properties": {
                "available": {
                  "type": "boolean"
                },
                "capabilities": {
                  "additionalProperties": {
                    "type": "boolean"
                  },
                  "propertyNames": {
                    "type": "string"
                  },
                  "type": "object"
                },
                "capability": {
                  "type": "string"
                },
                "context_window": {
                  "anyOf": [
                    {
                      "maximum": 9007199254740991,
                      "minimum": -9007199254740991,
                      "type": "integer"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "cost_hint": {
                  "anyOf": [
                    {
                      "additionalProperties": false,
                      "properties": {
                        "relative": {
                          "maximum": 5,
                          "minimum": 1,
                          "type": "integer"
                        },
                        "scale_max": {
                          "exclusiveMinimum": 0,
                          "maximum": 9007199254740991,
                          "type": "integer"
                        }
                      },
                      "required": [
                        "relative",
                        "scale_max"
                      ],
                      "type": "object"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "deprecation": {
                  "anyOf": [
                    {
                      "additionalProperties": false,
                      "properties": {
                        "announced_for": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "replacement": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "retires_on": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "announced_for",
                        "retires_on",
                        "replacement"
                      ],
                      "type": "object"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "description": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "display_name": {
                  "type": "string"
                },
                "fallback": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "family": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "icon_key": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "id": {
                  "type": "string"
                },
                "input_modalities": {
                  "anyOf": [
                    {
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "max_output_tokens": {
                  "anyOf": [
                    {
                      "maximum": 9007199254740991,
                      "minimum": -9007199254740991,
                      "type": "integer"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "max_reasoning_tokens": {
                  "anyOf": [
                    {
                      "maximum": 9007199254740991,
                      "minimum": -9007199254740991,
                      "type": "integer"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "media_constraints": {
                  "anyOf": [
                    {
                      "additionalProperties": false,
                      "properties": {
                        "supported_durations": {
                          "items": {
                            "exclusiveMinimum": 0,
                            "maximum": 9007199254740991,
                            "type": "integer"
                          },
                          "minItems": 1,
                          "type": "array"
                        },
                        "supported_resolutions": {
                          "items": {
                            "minLength": 1,
                            "type": "string"
                          },
                          "minItems": 1,
                          "type": "array"
                        }
                      },
                      "type": "object"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "output_modalities": {
                  "anyOf": [
                    {
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "provider_label": {
                  "type": "string"
                },
                "status": {
                  "enum": [
                    "active",
                    "preview",
                    "deprecated",
                    "retired"
                  ],
                  "type": "string"
                },
                "unavailable_reason": {
                  "anyOf": [
                    {
                      "enum": [
                        "plan_required",
                        "not_priced"
                      ],
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "required": [
                "id",
                "display_name",
                "provider_label",
                "capability",
                "family",
                "description",
                "icon_key",
                "status",
                "available",
                "unavailable_reason",
                "context_window",
                "max_output_tokens",
                "max_reasoning_tokens",
                "input_modalities",
                "output_modalities",
                "capabilities",
                "media_constraints",
                "cost_hint",
                "deprecation",
                "fallback"
              ],
              "type": "object"
            },
            "type": "array"
          },
          "defaults": {
            "additionalProperties": false,
            "properties": {
              "chat": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "guest": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "reasoning": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "vision": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "chat",
              "guest",
              "vision",
              "reasoning"
            ],
            "type": "object"
          }
        },
        "required": [
          "data",
          "defaults"
        ],
        "type": "object"
      },
      "AnthropicCountTokensResultDto": {
        "additionalProperties": false,
        "properties": {
          "input_tokens": {
            "maximum": 9007199254740991,
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "input_tokens"
        ],
        "type": "object"
      },
      "AnthropicCountTokensRequestDto": {
        "properties": {
          "messages": {
            "items": {
              "additionalProperties": {},
              "properties": {
                "content": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "items": {},
                      "type": "array"
                    }
                  ]
                },
                "role": {
                  "enum": [
                    "user",
                    "assistant",
                    "system"
                  ],
                  "type": "string"
                }
              },
              "required": [
                "role",
                "content"
              ],
              "type": "object"
            },
            "minItems": 1,
            "type": "array"
          },
          "model": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string"
          },
          "system": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "items": {},
                "type": "array"
              }
            ]
          },
          "tools": {
            "items": {},
            "type": "array"
          }
        },
        "required": [
          "model",
          "messages"
        ],
        "type": "object"
      },
      "AnthropicMessageResponseDto": {
        "properties": {
          "content": {
            "items": {},
            "type": "array"
          },
          "id": {
            "minLength": 1,
            "type": "string"
          },
          "model": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string"
          },
          "role": {
            "const": "assistant",
            "type": "string"
          },
          "stop_reason": {
            "anyOf": [
              {
                "enum": [
                  "end_turn",
                  "max_tokens",
                  "stop_sequence",
                  "tool_use",
                  "pause_turn",
                  "refusal"
                ],
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "stop_sequence": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "type": {
            "const": "message",
            "type": "string"
          },
          "usage": {
            "additionalProperties": {},
            "properties": {
              "input_tokens": {
                "maximum": 9007199254740991,
                "minimum": 0,
                "type": "integer"
              },
              "output_tokens": {
                "maximum": 9007199254740991,
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "input_tokens",
              "output_tokens"
            ],
            "type": "object"
          }
        },
        "required": [
          "id",
          "type",
          "role",
          "content",
          "model",
          "stop_reason",
          "stop_sequence",
          "usage"
        ],
        "type": "object"
      },
      "AnthropicMessagesRequestDto": {
        "properties": {
          "max_tokens": {
            "exclusiveMinimum": 0,
            "maximum": 9007199254740991,
            "type": "integer"
          },
          "messages": {
            "items": {
              "additionalProperties": {},
              "properties": {
                "content": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "items": {},
                      "type": "array"
                    }
                  ]
                },
                "role": {
                  "enum": [
                    "user",
                    "assistant",
                    "system"
                  ],
                  "type": "string"
                }
              },
              "required": [
                "role",
                "content"
              ],
              "type": "object"
            },
            "minItems": 1,
            "type": "array"
          },
          "model": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string"
          },
          "stream": {
            "type": "boolean"
          },
          "system": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "items": {},
                "type": "array"
              }
            ]
          },
          "temperature": {
            "type": "number"
          },
          "tools": {
            "items": {},
            "type": "array"
          }
        },
        "required": [
          "model",
          "messages",
          "max_tokens"
        ],
        "type": "object"
      },
      "OpenAiChatCompletionDto": {
        "additionalProperties": false,
        "properties": {
          "choices": {
            "items": {
              "additionalProperties": false,
              "properties": {
                "finish_reason": {
                  "anyOf": [
                    {
                      "enum": [
                        "stop",
                        "length",
                        "tool_calls",
                        "content_filter"
                      ],
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "index": {
                  "maximum": 9007199254740991,
                  "minimum": 0,
                  "type": "integer"
                },
                "message": {
                  "additionalProperties": false,
                  "properties": {
                    "content": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "role": {
                      "const": "assistant",
                      "type": "string"
                    },
                    "tool_calls": {
                      "items": {},
                      "type": "array"
                    }
                  },
                  "required": [
                    "role",
                    "content"
                  ],
                  "type": "object"
                }
              },
              "required": [
                "index",
                "message",
                "finish_reason"
              ],
              "type": "object"
            },
            "type": "array"
          },
          "created": {
            "maximum": 9007199254740991,
            "minimum": 0,
            "type": "integer"
          },
          "id": {
            "minLength": 1,
            "type": "string"
          },
          "model": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string"
          },
          "object": {
            "const": "chat.completion",
            "type": "string"
          },
          "usage": {
            "additionalProperties": false,
            "properties": {
              "completion_tokens": {
                "maximum": 9007199254740991,
                "minimum": 0,
                "type": "integer"
              },
              "prompt_tokens": {
                "maximum": 9007199254740991,
                "minimum": 0,
                "type": "integer"
              },
              "total_tokens": {
                "maximum": 9007199254740991,
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "prompt_tokens",
              "completion_tokens",
              "total_tokens"
            ],
            "type": "object"
          }
        },
        "required": [
          "id",
          "object",
          "created",
          "model",
          "choices",
          "usage"
        ],
        "type": "object"
      },
      "OpenAiChatRequestDto": {
        "properties": {
          "max_tokens": {
            "exclusiveMinimum": 0,
            "maximum": 9007199254740991,
            "type": "integer"
          },
          "messages": {
            "items": {
              "additionalProperties": {},
              "properties": {
                "content": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "items": {},
                      "type": "array"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "name": {
                  "type": "string"
                },
                "role": {
                  "enum": [
                    "system",
                    "user",
                    "assistant",
                    "tool"
                  ],
                  "type": "string"
                },
                "tool_call_id": {
                  "type": "string"
                },
                "tool_calls": {
                  "items": {},
                  "type": "array"
                }
              },
              "required": [
                "role"
              ],
              "type": "object"
            },
            "minItems": 1,
            "type": "array"
          },
          "model": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string"
          },
          "stream": {
            "type": "boolean"
          },
          "temperature": {
            "type": "number"
          },
          "tools": {
            "items": {},
            "type": "array"
          }
        },
        "required": [
          "model",
          "messages"
        ],
        "type": "object"
      }
    },
    "securitySchemes": {
      "cleTukai": {
        "type": "http",
        "scheme": "bearer",
        "description": "Clé tuk_sk_ dans Authorization: Bearer."
      },
      "cleTukaiEnTete": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "Clé tuk_sk_ dans x-api-key."
      }
    }
  }
}
