{
  "openapi": "3.1.0",
  "info": {
    "title": "Pareto API",
    "version": "1",
    "summary": "OpenAI-compatible chat completions and Anthropic-compatible messages for Pareto, the model from Unbiased.",
    "description": "Pareto is served at https://api.unbiased.ai/v1. It accepts OpenAI Chat Completions requests at POST /chat/completions and Anthropic Messages requests at POST /messages. Send the model string `pareto`. This spec documents the core fields; the API follows the OpenAI and Anthropic request formats, so existing clients work by changing the base URL, key and model string.\n\nAuthentication: an API key from a platform.unbiased.ai account, sent as `Authorization: Bearer <api-key>` or in the `x-api-key` header.\n\nRate limits are per account and depend on the plan: Personal 20 requests per minute and 25M tokens a week, Personal Max 60 requests per minute and 300M tokens a week, Team 300 requests per minute with no weekly token cap. Requests over the limit return HTTP 429.\n\nKnown gaps during the private beta: GET /models is not implemented, and unknown model ids are not rejected yet, so always send `pareto` explicitly.\n\nVersioning: the major version is in the URL path (/v1). Product changes are announced at https://unbiased.ai/changelog/.\n\nHuman-readable docs: https://unbiased.ai/developers/",
    "termsOfService": "https://unbiased.ai/terms/",
    "contact": {
      "name": "Unbiased",
      "url": "https://unbiased.ai/contact/",
      "email": "info@unbiased.ai"
    }
  },
  "externalDocs": {
    "description": "Developer docs, including examples and agent setup instructions",
    "url": "https://unbiased.ai/developers/"
  },
  "servers": [
    {
      "url": "https://api.unbiased.ai/v1",
      "description": "Production"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    },
    {
      "apiKeyHeader": []
    }
  ],
  "tags": [
    {
      "name": "OpenAI-compatible",
      "description": "OpenAI Chat Completions format"
    },
    {
      "name": "Anthropic-compatible",
      "description": "Anthropic Messages format"
    }
  ],
  "paths": {
    "/chat/completions": {
      "post": {
        "operationId": "createChatCompletion",
        "summary": "Create a chat completion",
        "description": "Send a conversation in the OpenAI Chat Completions format and get Pareto's reply. Set `stream: true` for server-sent events in the OpenAI streaming format.",
        "tags": [
          "OpenAI-compatible"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChatCompletionRequest"
              },
              "example": {
                "model": "pareto",
                "messages": [
                  {
                    "role": "user",
                    "content": "Summarize this diff in one sentence."
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The completion. With `stream: true`, a text/event-stream of chunks instead.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatCompletionResponse"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string",
                  "description": "OpenAI-format streaming chunks, ending with `data: [DONE]`."
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/OpenAIError"
          },
          "401": {
            "$ref": "#/components/responses/OpenAIError"
          },
          "429": {
            "$ref": "#/components/responses/OpenAIError"
          },
          "500": {
            "$ref": "#/components/responses/OpenAIError"
          }
        }
      }
    },
    "/messages": {
      "post": {
        "operationId": "createMessage",
        "summary": "Create a message",
        "description": "Send a conversation in the Anthropic Messages format and get Pareto's reply. Set `stream: true` for server-sent events in the Anthropic streaming format.",
        "tags": [
          "Anthropic-compatible"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MessageRequest"
              },
              "example": {
                "model": "pareto",
                "max_tokens": 1024,
                "messages": [
                  {
                    "role": "user",
                    "content": "Summarize this diff in one sentence."
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The message. With `stream: true`, a text/event-stream of events instead.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageResponse"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string",
                  "description": "Anthropic-format streaming events."
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/AnthropicError"
          },
          "401": {
            "$ref": "#/components/responses/AnthropicError"
          },
          "429": {
            "$ref": "#/components/responses/AnthropicError"
          },
          "500": {
            "$ref": "#/components/responses/AnthropicError"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "API key from platform.unbiased.ai, sent as `Authorization: Bearer <api-key>`."
      },
      "apiKeyHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "The same API key, sent in the `x-api-key` header."
      }
    },
    "responses": {
      "OpenAIError": {
        "description": "Error in the OpenAI format. 400 invalid request, 401 missing or invalid key, 429 rate limit reached, 500 server error.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/OpenAIError"
            },
            "example": {
              "error": {
                "message": "Missing API key. Pass your key as \"Authorization: Bearer <api-key>\" or in the \"x-api-key\" header.",
                "type": "invalid_request_error",
                "code": "invalid_api_key"
              }
            }
          }
        }
      },
      "AnthropicError": {
        "description": "Error in the Anthropic format. 400 invalid request, 401 missing or invalid key, 429 rate limit reached, 500 server error.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AnthropicError"
            },
            "example": {
              "type": "error",
              "error": {
                "type": "authentication_error",
                "message": "Missing API key. Pass your key as \"Authorization: Bearer <api-key>\" or in the \"x-api-key\" header."
              },
              "request_id": "req_8c6a9414bfdbc805a4c3c92e80e70537"
            }
          }
        }
      }
    },
    "schemas": {
      "Model": {
        "type": "string",
        "const": "pareto",
        "description": "The model string. Always send `pareto`."
      },
      "ChatMessage": {
        "type": "object",
        "required": [
          "role",
          "content"
        ],
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "system",
              "developer",
              "user",
              "assistant",
              "tool"
            ]
          },
          "content": {
            "description": "Text, or an array of OpenAI content parts.",
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "object"
                }
              }
            ]
          }
        }
      },
      "ChatCompletionRequest": {
        "type": "object",
        "required": [
          "model",
          "messages"
        ],
        "properties": {
          "model": {
            "$ref": "#/components/schemas/Model"
          },
          "messages": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/ChatMessage"
            }
          },
          "stream": {
            "type": "boolean",
            "default": false
          },
          "max_tokens": {
            "type": "integer",
            "minimum": 1
          },
          "temperature": {
            "type": "number",
            "minimum": 0,
            "maximum": 2
          },
          "tools": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Tool definitions in the OpenAI format."
          }
        }
      },
      "ChatCompletionResponse": {
        "type": "object",
        "required": [
          "id",
          "object",
          "choices"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "const": "chat.completion"
          },
          "created": {
            "type": "integer"
          },
          "model": {
            "type": "string"
          },
          "choices": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "index": {
                  "type": "integer"
                },
                "message": {
                  "$ref": "#/components/schemas/AssistantMessage"
                },
                "finish_reason": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              }
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "prompt_tokens": {
                "type": "integer"
              },
              "completion_tokens": {
                "type": "integer"
              },
              "total_tokens": {
                "type": "integer"
              }
            }
          }
        }
      },
      "MessageRequest": {
        "type": "object",
        "required": [
          "model",
          "max_tokens",
          "messages"
        ],
        "properties": {
          "model": {
            "$ref": "#/components/schemas/Model"
          },
          "max_tokens": {
            "type": "integer",
            "minimum": 1
          },
          "system": {
            "description": "System prompt as text or an array of text blocks.",
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "object"
                }
              }
            ]
          },
          "messages": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "required": [
                "role",
                "content"
              ],
              "properties": {
                "role": {
                  "type": "string",
                  "enum": [
                    "user",
                    "assistant"
                  ]
                },
                "content": {
                  "oneOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  ]
                }
              }
            }
          },
          "stream": {
            "type": "boolean",
            "default": false
          },
          "temperature": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "tools": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Tool definitions in the Anthropic format."
          }
        }
      },
      "MessageResponse": {
        "type": "object",
        "required": [
          "id",
          "type",
          "role",
          "content"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "const": "message"
          },
          "role": {
            "type": "string",
            "const": "assistant"
          },
          "model": {
            "type": "string"
          },
          "content": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "stop_reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "usage": {
            "type": "object",
            "properties": {
              "input_tokens": {
                "type": "integer"
              },
              "output_tokens": {
                "type": "integer"
              }
            }
          }
        }
      },
      "OpenAIError": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "message",
              "type"
            ],
            "properties": {
              "message": {
                "type": "string",
                "description": "Human-readable explanation."
              },
              "type": {
                "type": "string",
                "description": "Error category, for example invalid_request_error."
              },
              "code": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Machine-readable code, for example invalid_api_key."
              }
            }
          }
        }
      },
      "AnthropicError": {
        "type": "object",
        "required": [
          "type",
          "error"
        ],
        "properties": {
          "type": {
            "type": "string",
            "const": "error"
          },
          "error": {
            "type": "object",
            "required": [
              "type",
              "message"
            ],
            "properties": {
              "type": {
                "type": "string",
                "description": "Error category, for example authentication_error."
              },
              "message": {
                "type": "string",
                "description": "Human-readable explanation."
              }
            }
          },
          "request_id": {
            "type": "string"
          }
        }
      },
      "AssistantMessage": {
        "type": "object",
        "required": [
          "role"
        ],
        "properties": {
          "role": {
            "type": "string",
            "const": "assistant"
          },
          "content": {
            "type": [
              "string",
              "null"
            ],
            "description": "Reply text; null when the reply is only tool calls."
          },
          "tool_calls": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Tool calls in the OpenAI format."
          }
        }
      }
    }
  }
}
