{
  "openapi": "3.0.0",
  "info": {
    "description": "OpenAPI specification for the entire Messari API",
    "title": "Messari API - Ai Vercel",
    "version": "1.0.0"
  },
  "servers": [
    {
      "description": "Messari API",
      "url": "https://api.messari.io"
    }
  ],
  "security": [],
  "paths": {
    "/ai/vercel/chat/completions": {
      "post": {
        "description": "Processes a conversation and returns an AI-generated response in Vercel AI SDK compatible format. Consumes 5 credits per request.",
        "operationId": "postChatCompletionVercel",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChatCompletionRequestVercel"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "charts": {
                      "description": "Chart data referenced in the response",
                      "items": {
                        "properties": {
                          "dataset": {
                            "description": "Name of the dataset used for the chart",
                            "type": "string"
                          },
                          "end": {
                            "description": "End date for chart data range (RFC3339 format)",
                            "type": "string"
                          },
                          "entities": {
                            "description": "Entities (e.g., assets, protocols) included in the chart",
                            "items": {
                              "type": "string"
                            },
                            "type": "array"
                          },
                          "id": {
                            "description": "Unique identifier for the chart",
                            "type": "string"
                          },
                          "metric": {
                            "description": "Metric represented in the chart",
                            "type": "string"
                          },
                          "sourceType": {
                            "description": "Type of chart source, always 'chart'",
                            "type": "string"
                          },
                          "start": {
                            "description": "Start date for chart data range (RFC3339 format)",
                            "type": "string"
                          }
                        },
                        "required": [
                          "dataset",
                          "end",
                          "entities",
                          "id",
                          "metric",
                          "sourceType",
                          "start"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "error": {
                      "description": "Error message if the completion request failed",
                      "type": "string"
                    },
                    "metadata": {
                      "description": "Additional metadata about the completion",
                      "properties": {
                        "finishReason": {
                          "description": "Reason the model stopped generating (e.g., 'stop')",
                          "type": "string"
                        },
                        "traceId": {
                          "description": "Unique identifier for tracing the request",
                          "type": "string"
                        },
                        "usage": {
                          "description": "Token usage information",
                          "properties": {
                            "completionTokens": {
                              "description": "Number of tokens in the completion",
                              "format": "int64",
                              "type": "integer"
                            },
                            "promptTokens": {
                              "description": "Number of tokens in the prompt",
                              "format": "int64",
                              "type": "integer"
                            }
                          },
                          "required": [
                            "completionTokens",
                            "promptTokens"
                          ],
                          "type": "object"
                        }
                      },
                      "required": [
                        "traceId"
                      ],
                      "type": "object"
                    },
                    "sources": {
                      "description": "Citations and sources referenced in the response",
                      "items": {
                        "properties": {
                          "domain": {
                            "description": "Domain of the source URL",
                            "type": "string"
                          },
                          "id": {
                            "description": "Unique identifier for the source",
                            "type": "string"
                          },
                          "sourceType": {
                            "description": "Type of source (e.g., 'url')",
                            "type": "string"
                          },
                          "title": {
                            "description": "Title of the source document",
                            "type": "string"
                          },
                          "url": {
                            "description": "URL of the source if applicable",
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "sourceType"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "text_chunks": {
                      "description": "Sequential chunks of text content in the response",
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "metadata"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Bad Request"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Unauthorized"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {},
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Internal Server Error"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Generate chat completions in Vercel AI format"
      }
    }
  },
  "components": {
    "schemas": {
      "ChatCompletionRequestVercel": {
        "properties": {
          "allow_clarification_query": {
            "description": "Whether the AI can ask for clarification when the query is ambiguous",
            "type": "boolean"
          },
          "inline_citations": {
            "description": "Whether to include source citations inline in the response text",
            "type": "boolean"
          },
          "messages": {
            "description": "Array of messages in the conversation history",
            "items": {
              "$ref": "#/components/schemas/ChatCompletionMessage"
            },
            "type": "array"
          },
          "response_format": {
            "description": "Format style for the response content",
            "type": "string"
          },
          "verbosity": {
            "description": "Controls the level of detail in the response (concise, moderate, detailed)",
            "type": "string"
          }
        },
        "required": [
          "messages",
          "inline_citations",
          "allow_clarification_query"
        ],
        "type": "object"
      },
      "ChatCompletionMessage": {
        "type": "object",
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "user",
              "assistant",
              "system"
            ],
            "default": "user",
            "description": "The role of the message author"
          },
          "content": {
            "type": "string",
            "default": "What is Solana?",
            "description": "The content of the message"
          }
        },
        "required": [
          "role",
          "content"
        ]
      }
    },
    "securitySchemes": {
      "apiKey": {
        "in": "header",
        "name": "X-Messari-API-Key",
        "type": "apiKey"
      }
    }
  }
}
