{
  "openapi": "3.0.3",
  "info": {
    "title": "Valyu API",
    "version": "2.3.0",
    "description": "The search API built for AI agents. One API that gives your AI unified access to web search, academic papers, financial data, SEC filings, clinical trials, patents, genomics, and 40+ proprietary data sources.\n\n## Products\n\n| Product | Endpoint | Description |\n| --- | --- | --- |\n| **Search** | `POST /v1/search` | Multi-source search across web and proprietary datasets |\n| **Contents** | `POST /v1/contents` | Extract clean, structured content from URLs |\n| **Answer** | `POST /v1/answer` | AI-powered answers with real-time search |\n| **DeepResearch** | `POST /v1/deepresearch/tasks` | Async research agents for comprehensive analysis |\n| **Workflows** (Beta) | `GET /v1/workflows` | Templated, versioned DeepResearch for repeatable knowledge work |\n| **Datasources** | `GET /v1/datasources` | Discover available data sources and their schemas |\n\n## Authentication\n\nAll endpoints require an API key passed via the `X-API-Key` header (the lowercase `x-api-key` form is also accepted). Get your key at [platform.valyu.ai](https://platform.valyu.ai).\n\n```\nX-API-Key: your_api_key_here\n```\n\n## Pricing\n\nPay per use in credits. One credit balance covers every API.\n- **Search**: priced per result returned. Web and news results use 0.1 credits each (100 per 1,000 results). arXiv, PubMed, bioRxiv and medRxiv use 0.05 credits each (50 per 1,000). Other datasets have their own price per 1,000 results, listed in `GET /v1/datasources` (`pricing.cpm`).\n- **Contents**: 0.2 credits per successfully extracted URL. Any AI processing (a text summary or structured extraction through `summary`) brings the price to 0.6 credits per URL in total, the same for both. Failed URLs are free.\n- **Answer**: no per-request fee. You pay for the search, content extraction and AI processing each answer uses, reported in `cost.total_deduction_dollars`.\n- **DeepResearch**: fixed price per task by mode: instant 8 credits, fast 25, standard 100, heavy 500, max 2,500, plus tool add-ons.\n\nEvery plan includes web search and open academic sources. Paid plans unlock specialist sources such as SEC filings, clinical trials, patents and genomics. See [pricing](https://docs.valyu.ai/pricing) for plans and free credits.\n\n## Rate limits\n\nLimits apply per organisation: 10 requests per second with bursts up to 20, and 86,400 requests per day by default. Enterprise plans can raise them. A request over the limit is currently rejected with `403 Forbidden` and the body `{\"error\": \"Forbidden\", \"message\": \"Access denied - API key is invalid, disabled, or revoked\"}`. If a key that otherwise works starts receiving 403 under load, reduce concurrency and retry with exponential backoff.\n\n## SDKs\n\n- [Python SDK](https://pypi.org/project/valyu/) - `pip install valyu`\n- [TypeScript SDK](https://www.npmjs.com/package/valyu-js) - `npm install valyu-js`\n",
    "contact": {
      "name": "Valyu Support",
      "url": "https://valyu.ai",
      "email": "support@valyu.ai"
    },
    "x-logo": {
      "url": "https://valyu.ai/logo.png",
      "altText": "Valyu"
    }
  },
  "servers": [
    {
      "url": "https://api.valyu.ai",
      "description": "Production"
    }
  ],
  "security": [
    {
      "ApiKeyAuth": []
    }
  ],
  "tags": [
    {
      "name": "Search",
      "description": "Search across web, academic, financial, and proprietary data sources. Returns results ready for RAG pipelines, AI agents, and applications.",
      "externalDocs": {
        "description": "Search API Guide",
        "url": "https://docs.valyu.ai/search/quickstart"
      }
    },
    {
      "name": "Contents",
      "description": "Extract clean, structured content from web pages at scale. Supports batch processing, AI-powered summaries, structured extraction via JSON schemas, and async jobs for large URL sets.",
      "externalDocs": {
        "description": "Contents API Guide",
        "url": "https://docs.valyu.ai/guides/content-extraction"
      }
    },
    {
      "name": "Answer",
      "description": "Get AI-powered answers grounded in real-time search results. The Answer API searches across web, academic, and financial sources, then uses AI to generate a readable response via Server-Sent Events streaming.",
      "externalDocs": {
        "description": "Answer API Guide",
        "url": "https://docs.valyu.ai/guides/answer-api"
      }
    },
    {
      "name": "DeepResearch",
      "description": "Async research agents that perform comprehensive, multi-step research. DeepResearch searches multiple sources, analyzes content, and generates detailed reports with citations. Tasks run in the background and can take minutes to complete.",
      "externalDocs": {
        "description": "DeepResearch Guide",
        "url": "https://docs.valyu.ai/guides/deepresearch"
      }
    },
    {
      "name": "Batches",
      "description": "Run multiple DeepResearch tasks in parallel with shared configuration, unified monitoring, and aggregated cost tracking.",
      "externalDocs": {
        "description": "Batch API Guide",
        "url": "https://docs.valyu.ai/guides/deepresearch-batch-quickstart"
      }
    },
    {
      "name": "Workflows",
      "description": "**Beta.** Templated, versioned DeepResearch for repeatable knowledge work - earnings previews, diligence reads, market sizings. A workflow bundles a prompt template with typed variables, a research strategy, report format, deliverables, tools, and a recommended mode. Workflows are immutably versioned; runs can pin a version. Two scopes exist: your organization's private workflows and curated Valyu workflows available to everyone. Run a workflow by passing `workflow_id` + `workflow_params` to `POST /v1/deepresearch/tasks` - same auth, billing, and task lifecycle as freeform DeepResearch.",
      "externalDocs": {
        "description": "Workflows Guide (Beta)",
        "url": "https://docs.valyu.ai/guides/workflows"
      }
    },
    {
      "name": "Datasources",
      "description": "Discover available data sources and their schemas. A tool manifest for AI agents - instead of hardcoding knowledge of available datasets, agents can query this API to discover sources, filter by category, and use `example_queries` for few-shot prompting.",
      "externalDocs": {
        "description": "Datasources Guide",
        "url": "https://docs.valyu.ai/guides/datasources"
      }
    }
  ],
  "paths": {
    "/v1/search": {
      "post": {
        "operationId": "search",
        "summary": "Search across web and proprietary data sources",
        "description": "Search web pages and available academic, financial and specialist datasets. Returns ranked results with source URLs and extracted content for your application. Use source controls to choose the retrieval scope and inspect the catalog for source availability.\n\nUse Search when you control downstream reasoning. Use [DeepResearch](https://docs.valyu.ai/guides/deepresearch) when you want to delegate an investigation and receive a report.",
        "tags": [
          "Search"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SearchRequest"
              },
              "examples": {
                "basic": {
                  "summary": "Basic web search",
                  "value": {
                    "query": "latest developments in quantum computing",
                    "max_num_results": 5
                  }
                },
                "academic": {
                  "summary": "Academic paper search",
                  "value": {
                    "query": "CRISPR gene editing clinical trials 2024",
                    "search_type": "proprietary",
                    "max_num_results": 10,
                    "included_sources": [
                      "medical"
                    ]
                  }
                },
                "filtered": {
                  "summary": "Source-filtered search with date range",
                  "value": {
                    "query": "climate change impact on agriculture",
                    "included_sources": [
                      "valyu/valyu-arxiv",
                      "valyu/valyu-pubmed",
                      "valyu/valyu-biorxiv"
                    ],
                    "start_date": "2024-01-01",
                    "end_date": "2024-12-31",
                    "max_num_results": 10
                  }
                },
                "pubmed_abstracts": {
                  "summary": "PubMed abstract search",
                  "value": {
                    "query": "clonal hematopoiesis cardiovascular disease",
                    "included_sources": [
                      "valyu/valyu-pubmed"
                    ],
                    "include_abstracts": true,
                    "max_num_results": 10
                  }
                },
                "fast": {
                  "summary": "Low-latency web search",
                  "value": {
                    "query": "Tesla stock price today",
                    "fast_mode": true,
                    "max_num_results": 5
                  }
                },
                "strict": {
                  "summary": "Search every listed dataset (strict scope)",
                  "value": {
                    "query": "GLP-1 receptor agonist cardiovascular outcomes",
                    "included_sources": [
                      "valyu/valyu-pubmed",
                      "valyu/valyu-arxiv"
                    ],
                    "scope_policy": "strict",
                    "max_num_results": 10
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Search completed successfully with results.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchResponse"
                },
                "examples": {
                  "success": {
                    "summary": "Illustrative response with two results; not live findings",
                    "value": {
                      "success": true,
                      "error": null,
                      "tx_id": "tx_a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                      "query": "latest developments in quantum computing",
                      "results": [
                        {
                          "id": "https://example.com/research/source-1",
                          "title": "Illustrative research source 1",
                          "url": "https://example.com/research/source-1",
                          "content": "Illustrative source 1 text. Replace this placeholder with the actual returned evidence.",
                          "description": "Placeholder source text for the response format.",
                          "source": "web",
                          "price": 0.000625,
                          "length": 87,
                          "image_url": {},
                          "relevance_score": 0.95,
                          "data_type": "unstructured",
                          "source_type": "website",
                          "publication_date": "2024-06-15"
                        },
                        {
                          "id": "https://example.com/research/source-2",
                          "title": "Illustrative research source 2",
                          "url": "https://example.com/research/source-2",
                          "content": "Illustrative source 2 text. Replace this placeholder with the actual returned evidence.",
                          "description": "Placeholder source text for the response format.",
                          "source": "valyu/valyu-arxiv",
                          "price": 0.0003125,
                          "length": 87,
                          "image_url": {},
                          "relevance_score": 0.89,
                          "data_type": "unstructured",
                          "source_type": "paper",
                          "publication_date": "2024-01-15"
                        }
                      ],
                      "results_by_source": {
                        "web": 1,
                        "proprietary": 1
                      },
                      "total_deduction_dollars": 0.0009375,
                      "total_characters": 174
                    }
                  },
                  "fast_mode": {
                    "summary": "Illustrative fast-mode response with one result",
                    "value": {
                      "success": true,
                      "error": null,
                      "tx_id": "tx_fast12345-6789-abcd-ef01-234567890abc",
                      "query": "Tesla stock price today",
                      "results": [
                        {
                          "id": "https://example.com/market-update",
                          "title": "Illustrative market update",
                          "url": "https://example.com/market-update",
                          "content": "Placeholder market information; not a live price quote.",
                          "source": "web",
                          "price": 0.000625,
                          "length": 55,
                          "data_type": "unstructured",
                          "source_type": "website"
                        }
                      ],
                      "results_by_source": {
                        "web": 1
                      },
                      "total_deduction_dollars": 0.000625,
                      "total_characters": 55
                    }
                  },
                  "strict_scope": {
                    "summary": "Illustrative strict-scope response with a source_scope receipt",
                    "value": {
                      "success": true,
                      "error": null,
                      "tx_id": "tx_strict12-3456-7890-abcd-ef1234567890",
                      "query": "GLP-1 receptor agonist cardiovascular outcomes",
                      "results": [
                        {
                          "id": "https://example.com/research/source-3",
                          "title": "Illustrative research source 3",
                          "url": "https://example.com/research/source-3",
                          "content": "Illustrative source 3 text. Replace this placeholder with the actual returned evidence.",
                          "source": "valyu/valyu-pubmed",
                          "price": 0.0003125,
                          "length": 87,
                          "data_type": "unstructured",
                          "source_type": "paper"
                        }
                      ],
                      "results_by_source": {
                        "web": 0,
                        "proprietary": 1
                      },
                      "total_deduction_dollars": 0.0003125,
                      "total_characters": 87,
                      "source_scope": {
                        "policy": "strict",
                        "allowed_dataset_ids": [
                          "valyu/valyu-arxiv",
                          "valyu/valyu-pubmed"
                        ],
                        "selected_dataset_ids": [
                          "valyu/valyu-arxiv",
                          "valyu/valyu-pubmed"
                        ],
                        "completed_dataset_ids": [],
                        "returned_dataset_ids": [
                          "valyu/valyu-pubmed"
                        ],
                        "omitted_dataset_ids": [],
                        "selection_basis": "dispatch_requested",
                        "coverage": "unknown",
                        "exhaustive": false,
                        "errors": []
                      }
                    }
                  }
                }
              }
            }
          },
          "206": {
            "description": "Partial success - some sources failed or no results found, but the request was processed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchResponse"
                }
              }
            }
          },
          "400": {
            "description": "The request was malformed or contained invalid parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "invalid_parameter": {
                    "summary": "Invalid parameter",
                    "value": {
                      "success": false,
                      "error": "Invalid search_type. Must be 'all', 'web', 'proprietary', or 'news'"
                    }
                  },
                  "max_price": {
                    "summary": "max_price below the worst-case cost",
                    "value": {
                      "success": false,
                      "error": "Insufficient max_price. Search requires max_price >= 6.25 for your query"
                    }
                  },
                  "sub_day_dates": {
                    "summary": "Sub-day dates without historical_cache",
                    "value": {
                      "success": false,
                      "error": "Sub-day timestamps in start_date/end_date require historical_cache=true. Use YYYY-MM-DD for standard search."
                    }
                  },
                  "invalid_scope_policy": {
                    "summary": "scope_policy is not advisory or strict",
                    "value": {
                      "success": false,
                      "error": "invalid_scope_policy"
                    }
                  },
                  "invalid_strict_source_scope": {
                    "summary": "Strict scope without a valid list of dataset IDs",
                    "value": {
                      "success": false,
                      "error": "invalid_strict_source_scope"
                    }
                  },
                  "unsupported_strict_source": {
                    "summary": "Strict scope names a dataset Search cannot serve",
                    "value": {
                      "success": false,
                      "error": "unsupported_strict_source"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "description": "The key is disabled, revoked or lacks permission, or the requested sources are not available to this key.\n\n- `tier_insufficient` - every requested dataset is above your plan. If only some are, those are skipped, the rest are searched and the response carries a `datasets_not_in_plan` warning. `recovery` has `current_plan`, `required_plan` (`{id, name, price}` or `null`), `required_tier` and `upgrade_url`.\n- `dataset_unavailable` - every requested dataset is licensed or unknown. `recovery` has `current_plan`, `contact_url` and `datasources_url`.\n- `dataset_outside_task_scope` - with `scope_policy: \"strict\"`, at least one listed dataset is outside your plan or grants. Strict scope never falls back to a partial search.\n- `deepresearch_only` - every requested dataset is DeepResearch-only. Mixed with other sources, DeepResearch-only datasets are skipped with a `datasets_deepresearch_only` warning.\n\nA request over the rate limit returns `429`, not `403`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "forbidden": {
                    "summary": "Key disabled or revoked",
                    "value": {
                      "error": "Forbidden",
                      "message": "Access denied - API key is invalid, disabled, or revoked"
                    }
                  },
                  "tier_insufficient": {
                    "summary": "Requested datasets are above your plan",
                    "value": {
                      "success": false,
                      "error": "Your current plan (tier_1) does not include access to: valyu/valyu-clinical-trials. Upgrade your plan to access these data sources.",
                      "code": "tier_insufficient",
                      "recovery": {
                        "current_plan": "tier_1",
                        "required_plan": {
                          "id": "tier_2",
                          "name": "Comfortably Pro",
                          "price": "$99/mo"
                        },
                        "required_tier": "tier_2",
                        "upgrade_url": "https://platform.valyu.ai/user/account/billing?tab=plan",
                        "available_datasets": [
                          "valyu/valyu-arxiv",
                          "valyu/valyu-biorxiv",
                          "valyu/valyu-medrxiv",
                          "valyu/valyu-pubmed"
                        ]
                      }
                    }
                  },
                  "dataset_outside_task_scope": {
                    "summary": "Strict scope includes a dataset outside your access",
                    "value": {
                      "success": false,
                      "error": "dataset_outside_task_scope"
                    }
                  },
                  "deepresearch_only": {
                    "summary": "Only DeepResearch-only datasets requested (illustrative dataset ID)",
                    "value": {
                      "success": false,
                      "error": "One or more requested datasets are only available through DeepResearch.",
                      "restricted_sources": [
                        "example/deepresearch-only-dataset"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/v1/contents": {
      "post": {
        "operationId": "extractContents",
        "summary": "Extract clean, structured content from URLs",
        "description": "Extract content from URLs, with optional summaries, structured extraction and screenshots. Access or extraction can fail for individual URLs.\n\n- **Synchronous:** Submit up to 10 URLs and receive results directly.\n- **Asynchronous:** Set `async: true` for up to 50 URLs, save the returned `job_id` and poll the job endpoint. Requests with more than 10 URLs must use `async: true`.\n- **Partial success:** Inspect the result for each URL rather than treating the request as all-or-nothing.\n\n**Pricing:** 0.2 credits per successfully extracted URL. When `summary` is enabled (text summary or structured extraction), the price is 0.6 credits per URL in total. This applies to synchronous and async requests. Failed URLs are free. `total_cost_dollars` is the amount charged.",
        "tags": [
          "Contents"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContentsRequest"
              },
              "examples": {
                "basic": {
                  "summary": "Basic content extraction",
                  "value": {
                    "urls": [
                      "https://en.wikipedia.org/wiki/Quantum_computing"
                    ]
                  }
                },
                "With Summary": {
                  "summary": "Extraction with AI summary",
                  "value": {
                    "urls": [
                      "https://example.com/selected-paper"
                    ],
                    "summary": "Summarize the key findings and methodology",
                    "response_length": "medium"
                  }
                },
                "structured": {
                  "summary": "Structured data extraction with JSON schema",
                  "value": {
                    "urls": [
                      "https://example.com/product-page"
                    ],
                    "summary": {
                      "type": "object",
                      "properties": {
                        "product_name": {
                          "type": "string"
                        },
                        "price": {
                          "type": "number"
                        },
                        "features": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                },
                "Async Batch": {
                  "summary": "Async batch processing with webhook",
                  "value": {
                    "urls": [
                      "https://example.com/page1",
                      "https://example.com/page2"
                    ],
                    "async": true,
                    "webhook_url": "https://example.com/webhooks/valyu"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "All URLs processed successfully (synchronous).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContentsResponse"
                },
                "examples": {
                  "basic": {
                    "summary": "Illustrative extraction response with one successful URL",
                    "value": {
                      "success": true,
                      "error": null,
                      "tx_id": "tx_c1d2e3f4-a5b6-7890-cdef-123456789abc",
                      "urls_requested": 1,
                      "urls_processed": 1,
                      "urls_failed": 0,
                      "results": [
                        {
                          "url": "https://example.com/article",
                          "status": "success",
                          "title": "Illustrative article",
                          "content": "# Illustrative article\n\nPlaceholder text representing extracted page content.",
                          "description": "Placeholder article for demonstrating extraction.",
                          "source": "web",
                          "price": 0.00125,
                          "length": 77,
                          "data_type": "unstructured",
                          "source_type": "website",
                          "image_url": {}
                        }
                      ],
                      "total_cost_dollars": 0.00125,
                      "total_characters": 77
                    }
                  },
                  "structured": {
                    "summary": "Illustrative structured extraction (price is the 0.2 credit base; total_cost_dollars includes the 0.4 credit AI processing, 0.6 credits in total)",
                    "value": {
                      "success": true,
                      "error": null,
                      "tx_id": "tx_struct-1234-5678-abcd-ef0123456789",
                      "urls_requested": 1,
                      "urls_processed": 1,
                      "urls_failed": 0,
                      "results": [
                        {
                          "url": "https://example.com/product-page",
                          "status": "success",
                          "title": "Product Page",
                          "content": {
                            "product_name": "Example product",
                            "price": 29.99,
                            "features": [
                              "Feature A",
                              "Feature B"
                            ]
                          },
                          "source": "web",
                          "price": 0.00125,
                          "length": 91,
                          "data_type": "structured",
                          "summary_success": true
                        }
                      ],
                      "total_cost_dollars": 0.00375,
                      "total_characters": 91
                    }
                  }
                }
              }
            }
          },
          "202": {
            "description": "Async job created. Poll the `poll_url` for results.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContentsAsyncResponse"
                },
                "examples": {
                  "example": {
                    "summary": "Async job created",
                    "value": {
                      "success": true,
                      "job_id": "cj_a1b2c3d4e5f6g7h8",
                      "status": "pending",
                      "urls_total": 25,
                      "poll_url": "/contents/jobs/cj_a1b2c3d4e5f6g7h8",
                      "tx_id": "tx_async-1234-5678-abcd-ef0123456789",
                      "webhook_secret": "EXAMPLE_WEBHOOK_SECRET_REPLACE_WITH_RETURNED_VALUE"
                    }
                  }
                }
              }
            }
          },
          "206": {
            "description": "Partial success - some URLs failed processing.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContentsResponse"
                }
              }
            }
          },
          "400": {
            "description": "The request was malformed or contained invalid parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "async_required": {
                    "summary": "More than 10 URLs without async",
                    "value": {
                      "success": false,
                      "error": "Requests with more than 10 URLs require async processing. Set 'async': true in your request to process 12 URLs."
                    }
                  },
                  "too_many_urls": {
                    "summary": "More than 50 URLs",
                    "value": {
                      "success": false,
                      "error": "Maximum 50 URLs allowed per request"
                    }
                  },
                  "max_price": {
                    "summary": "Worst-case cost above max_price_dollars",
                    "value": {
                      "success": false,
                      "error": "Maximum possible cost $0.0375 exceeds max_price_dollars $0.01"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "description": "The request can't be paid for. See the shared payment errors: `insufficient_credits`, `credit_limit_reached` and `spend_cap_reached`.\n\nAlso returned after processing when the actual cost exceeds `max_price_dollars`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "insufficient_credits": {
                    "summary": "Balance exhausted",
                    "value": {
                      "success": false,
                      "error": "Your credit balance is used up. Nothing was charged. Top up to continue: https://platform.valyu.ai/user/account/billing?tab=credits Monthly plans give you cheaper credits and more data sources: https://platform.valyu.ai/user/account/billing?tab=plan",
                      "code": "insufficient_credits",
                      "recovery": {
                        "topup_url": "https://platform.valyu.ai/user/account/billing?tab=credits",
                        "topup_api": "POST https://api.valyu.ai/v1/account/balance/topup",
                        "upgrade_url": "https://platform.valyu.ai/user/account/billing?tab=plan"
                      }
                    }
                  },
                  "credit_limit_reached": {
                    "summary": "Monthly usage limit reached",
                    "value": {
                      "success": false,
                      "error": "Your organisation's monthly credit limit is reached. Nothing was charged. Raise the limit to continue: https://platform.valyu.ai/user/account/billing?tab=credits",
                      "code": "credit_limit_reached",
                      "recovery": {
                        "increase_limit_url": "https://platform.valyu.ai/user/account/billing?tab=credits"
                      }
                    }
                  },
                  "spend_cap_reached": {
                    "summary": "API key budget cap reached",
                    "value": {
                      "success": false,
                      "error": "This API key has reached its credit cap. Nothing was charged. Raise the key's cap or use an uncapped key: https://platform.valyu.ai/user/account/apikeys",
                      "code": "spend_cap_reached",
                      "recovery": {
                        "increase_cap_url": "https://platform.valyu.ai/user/account/apikeys"
                      }
                    }
                  },
                  "max_price_exceeded": {
                    "summary": "Actual cost above max_price_dollars",
                    "value": {
                      "success": false,
                      "error": "Actual cost $0.0125 exceeds max_price_dollars $0.01"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "422": {
            "description": "All URLs failed to process. No charge is applied.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": false
                    },
                    "error": {
                      "type": "string",
                      "description": "Why extraction failed."
                    },
                    "results": {
                      "type": "array",
                      "description": "Always empty.",
                      "items": {},
                      "example": []
                    }
                  }
                },
                "examples": {
                  "all_failed": {
                    "summary": "All URLs failed",
                    "value": {
                      "success": false,
                      "error": "Could not process the requested URL(s). See the per-result 'error' field for details.",
                      "results": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/v1/contents/jobs/{job_id}": {
      "get": {
        "operationId": "getContentsJob",
        "summary": "Poll async content extraction job status",
        "description": "Check the status and retrieve results of an async content extraction job.",
        "tags": [
          "Contents"
        ],
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The job ID returned by the async contents request.",
            "example": "cj_a1b2c3d4e5f6g7h8"
          }
        ],
        "responses": {
          "200": {
            "description": "Job status and results (when complete).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContentsJobResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/v1/answer": {
      "post": {
        "operationId": "answer",
        "deprecated": true,
        "summary": "Get AI-powered answers with real-time search",
        "description": "**Deprecated.** The Answer API sunsets on 2026-12-17. From that date this endpoint returns HTTP `410 Gone`. Until then it keeps working and its responses carry `Deprecation` and `Sunset` headers. For quick cited answers, use [DeepResearch](https://docs.valyu.ai/api-reference/endpoint/deepresearch-create) with `mode: \"instant\"`, or use [Search](https://docs.valyu.ai/api-reference/endpoint/search) with your own model. See [Migrate from Answer](https://docs.valyu.ai/api-reference/endpoint/answer#migrate-from-answer).\n\nSearches across web, academic, and financial sources, then uses AI to generate a readable, cited response. Returns results as a **Server-Sent Events (SSE)** stream.\n\nThe AI agent performs multi-round search with up to 2 tool call rounds (3 in `fast_mode`), can decompose queries into sub-queries, and synthesizes findings into a coherent answer.\n\n## SSE Event Types\n\nEvents are sent as `data: {json}\\n\\n` with the following types:\n\n| Event | Description |\n| --- | --- |\n| `search_results` | Search sources found (may occur multiple times) |\n| `content` | Partial answer text chunk (OpenAI-compatible delta format) |\n| `metadata` | Final metadata with costs, token usage, all search results and any `warnings` |\n| `error` | `{\"error\": \"Streaming failed\"}` if the answer fails mid-stream; the stream then ends |\n| `[DONE]` | Stream complete |\n\n## Cost Structure\n\nThere is no per-request fee. Each answer is charged for the search, content extraction and AI processing it uses. `cost.total_deduction_dollars` in the final `metadata` event is the amount billed, and each search result is billed once per answer. `data_max_price` caps only the search component, not the entire charge.",
        "tags": [
          "Answer"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnswerRequest"
              },
              "examples": {
                "basic": {
                  "summary": "Basic question",
                  "value": {
                    "query": "What are the latest FDA-approved treatments for type 2 diabetes?"
                  }
                },
                "structured": {
                  "summary": "Structured output with JSON schema",
                  "value": {
                    "query": "Compare the top 5 electric vehicles by range and price in 2024",
                    "structured_output": {
                      "type": "object",
                      "properties": {
                        "vehicles": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "name": {
                                "type": "string"
                              },
                              "range_miles": {
                                "type": "number"
                              },
                              "base_price": {
                                "type": "number"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "filtered": {
                  "summary": "Source-filtered with custom instructions",
                  "value": {
                    "query": "SEC enforcement actions against crypto exchanges",
                    "search_type": "proprietary",
                    "included_sources": [
                      "finance"
                    ],
                    "system_instructions": "You are a financial regulatory analyst. Focus on enforcement actions and penalties.",
                    "start_date": "2024-01-01"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "SSE stream of search results, answer chunks, and metadata.",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string",
                  "description": "Server-Sent Events stream. Each event has format: `data: {json}\\n\\n`\n\n**search_results event:**\n```json\n{\"search_results\": [{\"title\": \"...\", \"url\": \"...\", \"content\": \"...\", ...}]}\n```\n\n**content event (OpenAI-compatible):**\n```json\n{\"choices\": [{\"delta\": {\"role\": \"assistant\", \"content\": \"text chunk\"}, \"index\": 0}]}\n```\n\n**metadata event:**\n```json\n{\"success\": true, \"tx_id\": \"ai_tx_...\", \"original_query\": \"...\", \"contents\": \"Full answer text...\", \"search_results\": [{\"title\": \"...\", \"url\": \"...\", \"content\": \"...\", \"description\": \"...\", \"source\": \"web\", \"source_type\": \"website\", \"data_type\": \"unstructured\", \"date\": \"...\", \"length\": 1200, \"image_url\": {}}], \"search_metadata\": {\"tx_ids\": [\"tx_...\"], \"number_of_results\": 10, \"total_characters\": 50000}, \"ai_usage\": {\"input_tokens\": 15000, \"output_tokens\": 2000}, \"cost\": {\"total_deduction_dollars\": 0.0475, \"search_deduction_dollars\": 0.00625, \"ai_deduction_dollars\": 0.03625, \"contents_deduction_dollars\": 0.005}}\n```\n\n`contents` is the full answer (JSON text when `structured_output` is set). `total_deduction_dollars` is the amount billed. When the searches behind the answer skipped or adjusted something, the metadata event also carries `warnings`: the warnings of those searches, deduplicated, in the same `{type, message, detail}` shape as Search. See [Warnings](https://docs.valyu.ai/api-reference/warnings).\n\n**error event:**\n```json\n{\"error\": \"Streaming failed\"}\n```\n\n**done signal:**\n```\ndata: [DONE]\n```"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/v1/deepresearch/tasks": {
      "post": {
        "operationId": "createDeepResearch",
        "summary": "Create a DeepResearch task",
        "description": "Start an asynchronous investigation that retrieves information and produces a cited report, with optional generated files. Provide the research question, source controls and output requirements.\n\nSave the returned task ID and poll the status endpoint or configure a completion webhook. Execution time depends on the mode and task; handle queued, running and terminal states rather than relying on a fixed duration.\n\n**Billing.** When the task is created, its mode's base price is held against your balance. The hold is released when the task is charged, or when it ends without a charge. If your balance, minus amounts held for your other queued and running tasks, is below the price, or the charge would exceed your monthly usage limit, the request returns 402 and no task is created. If billing can't be checked, it returns 503 with no task created; retry with backoff.\n\nCompleted tasks are charged the mode price plus tool add-ons. Failed tasks are free. Cancelling a `running` or `awaiting_input` task charges the full mode price; cancelling a `queued` or `paused` task is free.",
        "tags": [
          "DeepResearch"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeepResearchCreateRequest"
              },
              "examples": {
                "basic": {
                  "summary": "Basic research task",
                  "value": {
                    "query": "Comprehensive analysis of CRISPR gene therapy clinical trials in 2024",
                    "mode": "standard"
                  }
                },
                "advanced": {
                  "summary": "Advanced research with PDF output and file attachments",
                  "value": {
                    "query": "Compare efficacy data across Phase 3 CRISPR trials",
                    "mode": "heavy",
                    "research_strategy": "Focus on safety profiles, patient outcomes, and regulatory pathways",
                    "output_formats": [
                      "markdown",
                      "pdf"
                    ],
                    "search": {
                      "search_type": "proprietary",
                      "included_sources": [
                        "medical"
                      ],
                      "start_date": "2023-01-01"
                    },
                    "urls": [
                      "https://example.com/selected-trial-record"
                    ],
                    "webhook_url": "https://example.com/webhooks/deepresearch"
                  }
                },
                "structured": {
                  "summary": "Structured JSON output",
                  "value": {
                    "query": "Top 10 AI companies by funding raised in 2024",
                    "mode": "fast",
                    "output_formats": [
                      {
                        "type": "object",
                        "properties": {
                          "companies": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "name": {
                                  "type": "string"
                                },
                                "funding_millions": {
                                  "type": "number"
                                },
                                "focus_area": {
                                  "type": "string"
                                }
                              }
                            }
                          }
                        }
                      }
                    ]
                  }
                },
                "shared": {
                  "summary": "Research and share with specific people",
                  "value": {
                    "query": "Market map of European battery recycling companies",
                    "mode": "standard",
                    "share_with": [
                      "anna@client.com",
                      "@acme.com"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Research task created and queued.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeepResearchCreateResponse"
                },
                "examples": {
                  "running": {
                    "summary": "Task started immediately",
                    "value": {
                      "deepresearch_id": "f992a8ab-4c91-4322-905f-190107bd5a5b",
                      "status": "running",
                      "mode": "standard",
                      "created_at": "2024-06-15T10:30:00.000Z",
                      "metadata": {
                        "project": "drug-discovery"
                      },
                      "public": false
                    }
                  },
                  "queued": {
                    "summary": "Task queued (capacity limit)",
                    "value": {
                      "deepresearch_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                      "status": "queued",
                      "mode": "heavy",
                      "created_at": "2024-06-15T10:30:00.000Z",
                      "public": false,
                      "message": "Task queued. Current position: 3",
                      "webhook_secret": "EXAMPLE_WEBHOOK_SECRET_REPLACE_WITH_RETURNED_VALUE"
                    }
                  },
                  "shared": {
                    "summary": "Task created and shared",
                    "value": {
                      "deepresearch_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                      "status": "running",
                      "mode": "standard",
                      "created_at": "2026-11-12T10:30:00.000Z",
                      "public": false,
                      "sharing": {
                        "share_url": "https://platform.valyu.ai/share/a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                        "shared_with": [
                          {
                            "email": "anna@client.com",
                            "added_at": "2026-11-12T10:30:00.000Z"
                          },
                          {
                            "domain": "acme.com",
                            "added_at": "2026-11-12T10:30:00.000Z"
                          }
                        ],
                        "notified": [
                          "anna@client.com"
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/DeepResearchPaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/v1/deepresearch/tasks/{id}/status": {
      "get": {
        "operationId": "getDeepResearchStatus",
        "summary": "Get DeepResearch task status and results",
        "description": "Retrieve the current status, progress, and results of a DeepResearch task. Poll this endpoint to track research progress and retrieve the final output.",
        "tags": [
          "DeepResearch"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "DeepResearch task ID.",
            "example": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          },
          {
            "name": "version",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            },
            "description": "Optional version number to retrieve. Returns that version's `output`, `sources`, `pdf_url`, and `deliverables`, plus `is_latest`. Only the task owner can read a non-head version.",
            "example": 1
          }
        ],
        "responses": {
          "200": {
            "description": "Task status and results.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeepResearchStatusResponse"
                },
                "examples": {
                  "running": {
                    "summary": "Task in progress",
                    "value": {
                      "deepresearch_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                      "status": "running",
                      "query": "Comprehensive analysis of CRISPR gene therapy clinical trials",
                      "mode": "standard",
                      "output_formats": [
                        "markdown",
                        "pdf"
                      ],
                      "created_at": "2024-06-15T10:30:00.000Z",
                      "public": false,
                      "progress": {
                        "current_step": 5,
                        "total_steps": 15
                      }
                    }
                  },
                  "completed": {
                    "summary": "Illustrative completed report; source records are placeholders",
                    "value": {
                      "deepresearch_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                      "status": "completed",
                      "query": "Comprehensive analysis of CRISPR gene therapy clinical trials",
                      "mode": "standard",
                      "output_formats": [
                        "markdown",
                        "pdf"
                      ],
                      "created_at": "2024-06-15T10:30:00.000Z",
                      "completed_at": "2024-06-15T10:42:00.000Z",
                      "public": false,
                      "output_type": "markdown",
                      "output": "# Illustrative research report\n\nThis placeholder shows the report format, not research findings. Example supporting material: [1](https://example.com/research/source-1) and [2](https://example.com/research/source-2).",
                      "sources": [
                        {
                          "title": "Illustrative evidence source 1",
                          "url": "https://example.com/research/source-1",
                          "snippet": "Placeholder passage for demonstrating source attribution.",
                          "source": "web"
                        },
                        {
                          "title": "Illustrative evidence source 2",
                          "url": "https://example.com/research/source-2",
                          "snippet": "Placeholder passage for demonstrating source attribution.",
                          "source": "web"
                        }
                      ],
                      "cost": 0.625,
                      "pdf_url": "https://example.com/reports/illustrative-report.pdf",
                      "images": [
                        {
                          "image_id": "img_chart001",
                          "image_type": "chart",
                          "deepresearch_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                          "title": "Illustrative report chart",
                          "image_url": "https://example.com/reports/illustrative-chart.png",
                          "chart_type": "bar",
                          "created_at": 1718447880000
                        }
                      ],
                      "cost_breakdown": {
                        "task": 0.625
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/v1/deepresearch/list": {
      "get": {
        "operationId": "listDeepResearchTasks",
        "summary": "List DeepResearch tasks",
        "description": "Retrieve a list of all DeepResearch tasks for the authenticated API key.",
        "tags": [
          "DeepResearch"
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            },
            "description": "Maximum number of tasks to return."
          }
        ],
        "responses": {
          "200": {
            "description": "List of DeepResearch tasks.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DeepResearchListItem"
                  }
                },
                "examples": {
                  "success": {
                    "summary": "List of research tasks",
                    "value": [
                      {
                        "deepresearch_id": "f992a8ab-4c91-4322-905f-190107bd5a5b",
                        "query": "CRISPR gene therapy clinical trials",
                        "status": "completed",
                        "created_at": "2024-06-15T10:30:00.000Z",
                        "public": false
                      },
                      {
                        "deepresearch_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                        "query": "Quantum computing market analysis",
                        "status": "running",
                        "created_at": "2024-06-15T11:00:00.000Z",
                        "public": false
                      }
                    ]
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/v1/deepresearch/tasks/{id}/update": {
      "post": {
        "operationId": "updateDeepResearch",
        "summary": "Add a follow-up instruction to a running task",
        "description": "Send a follow-up instruction to a running DeepResearch task. The instruction can only be added before the writing phase begins. Use this to steer the research in a specific direction based on intermediate findings.",
        "tags": [
          "DeepResearch"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "DeepResearch task ID."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeepResearchUpdateRequest"
              },
              "examples": {
                "Add Instruction": {
                  "summary": "Add follow-up instruction",
                  "value": {
                    "instruction": "Also compare the safety profiles across all trials"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Instruction added successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeepResearchUpdateResponse"
                },
                "examples": {
                  "success": {
                    "summary": "Task updated",
                    "value": {
                      "success": true,
                      "message": "Task updated successfully",
                      "deepresearch_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Task is not in a state that accepts updates (writing phase has started or task is not running).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/v1/deepresearch/tasks/{id}/cancel": {
      "post": {
        "operationId": "cancelDeepResearch",
        "summary": "Cancel a running or queued task",
        "description": "Cancel a DeepResearch task that is `running`, `queued`, `awaiting_input` or `paused`. Completed, failed or already cancelled tasks cannot be cancelled.\n\n**Billing:** cancelling a `running` or `awaiting_input` task charges the full mode price. Cancelling a `queued` or `paused` task is free.",
        "tags": [
          "DeepResearch"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "DeepResearch task ID."
          }
        ],
        "responses": {
          "200": {
            "description": "Task cancelled.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeepResearchCancelResponse"
                },
                "examples": {
                  "success": {
                    "summary": "Task cancelled",
                    "value": {
                      "success": true,
                      "message": "Task cancelled",
                      "deepresearch_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The task is not in a cancellable status.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "not_cancellable": {
                    "summary": "Task already finished",
                    "value": {
                      "error": "Cannot cancel task with status: completed. Only running, queued, awaiting_input, or paused tasks can be cancelled."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "The task's status changed while the cancel was being processed (for example, it just completed). Fetch the task status.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "conflict": {
                    "summary": "Task no longer cancellable",
                    "value": {
                      "error": "Task is no longer cancellable."
                    }
                  }
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/v1/deepresearch/tasks/{id}/delete": {
      "delete": {
        "operationId": "deleteDeepResearch",
        "summary": "Delete a completed, failed, or cancelled task",
        "description": "Permanently delete a DeepResearch task and its associated data (output, sources, PDF, images). Running or queued tasks must be cancelled first.",
        "tags": [
          "DeepResearch"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "DeepResearch task ID."
          }
        ],
        "responses": {
          "200": {
            "description": "Task deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeepResearchDeleteResponse"
                },
                "examples": {
                  "success": {
                    "summary": "Task deleted",
                    "value": {
                      "success": true,
                      "message": "Task deleted successfully",
                      "deepresearch_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Task cannot be deleted (still running or queued).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/v1/deepresearch/tasks/{id}/public": {
      "post": {
        "operationId": "toggleDeepResearchPublic",
        "summary": "Toggle public access for a task",
        "description": "Toggle the public visibility of a DeepResearch task. When set to `true`, the task results become accessible via a public share link without authentication. Only the task owner can modify the public flag.",
        "tags": [
          "DeepResearch"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "DeepResearch task ID."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeepResearchTogglePublicRequest"
              },
              "examples": {
                "Make Public": {
                  "summary": "Make task publicly accessible",
                  "value": {
                    "public": true
                  }
                },
                "Make Private": {
                  "summary": "Make task private",
                  "value": {
                    "public": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Public flag updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeepResearchTogglePublicResponse"
                },
                "examples": {
                  "Made Public": {
                    "summary": "Task made public",
                    "value": {
                      "success": true,
                      "message": "Public flag updated",
                      "deepresearch_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                      "public": true
                    }
                  },
                  "Made Private": {
                    "summary": "Task made private",
                    "value": {
                      "success": true,
                      "message": "Public flag updated",
                      "deepresearch_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                      "public": false
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request body.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/v1/deepresearch/tasks/{id}/share": {
      "get": {
        "operationId": "getDeepResearchSharing",
        "summary": "Get who a task is shared with",
        "description": "List the people and company domains a DeepResearch report is shared with, with the share link and whether the report is public. Only the API key that created the task can call this endpoint.",
        "tags": [
          "DeepResearch"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "DeepResearch task ID.",
            "example": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "Sharing for the task.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeepResearchShareResponse"
                },
                "examples": {
                  "shared": {
                    "summary": "Report shared with a person and a domain",
                    "value": {
                      "deepresearch_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                      "public": false,
                      "share_url": "https://platform.valyu.ai/share/a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                      "shared_with": [
                        {
                          "email": "anna@client.com",
                          "added_at": "2026-11-12T10:30:00.000Z",
                          "notified_at": "2026-11-12T10:30:01.000Z",
                          "last_viewed_at": "2026-11-12T14:05:00.000Z"
                        },
                        {
                          "domain": "acme.com",
                          "added_at": "2026-11-12T10:30:00.000Z"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The API key did not create this task, or the key is disabled or lacks permission. Only the API key that created the task can view or change who it is shared with.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "not_owner": {
                    "summary": "Key did not create the task",
                    "value": {
                      "error": "Only the task owner can share it",
                      "code": "task.not_owner"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      },
      "post": {
        "operationId": "updateDeepResearchSharing",
        "summary": "Share a task with specific people",
        "description": "Add or remove people and company domains who can open a DeepResearch report. The report stays private: only the people and domains it is shared with, and members of your organization, can open it after signing in to Valyu with a verified email address. Additions and removals apply together or not at all. Each person you add is emailed a link unless `notify` is `false`; domains are never emailed. A report can be shared with up to 100 people and domains. Only the API key that created the task can call this endpoint.\n\nSharing is independent of the `public` flag set with [Toggle public access](https://docs.valyu.ai/api-reference/endpoint/deepresearch-public).",
        "tags": [
          "DeepResearch"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "DeepResearch task ID.",
            "example": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeepResearchShareUpdateRequest"
              },
              "examples": {
                "add": {
                  "summary": "Share with a person",
                  "value": {
                    "add": [
                      "ben@client.com"
                    ]
                  }
                },
                "add_and_remove": {
                  "summary": "Add a person and remove a domain",
                  "value": {
                    "add": [
                      "ben@client.com"
                    ],
                    "remove": [
                      "@acme.com"
                    ],
                    "shared_by": "Maya at Northwind Capital"
                  }
                },
                "add_quietly": {
                  "summary": "Share with a domain without sending email",
                  "value": {
                    "add": [
                      "@client.com"
                    ],
                    "notify": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sharing updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeepResearchShareUpdateResponse"
                },
                "examples": {
                  "updated": {
                    "summary": "Person added and domain removed",
                    "value": {
                      "deepresearch_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                      "public": false,
                      "share_url": "https://platform.valyu.ai/share/a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                      "shared_with": [
                        {
                          "email": "anna@client.com",
                          "added_at": "2026-11-12T10:30:00.000Z",
                          "notified_at": "2026-11-12T10:30:01.000Z",
                          "last_viewed_at": "2026-11-12T14:05:00.000Z"
                        },
                        {
                          "email": "ben@client.com",
                          "added_at": "2026-11-12T15:00:00.000Z",
                          "notified_at": "2026-11-12T15:00:01.000Z"
                        }
                      ],
                      "notified": [
                        "ben@client.com"
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request: an invalid email address or domain, a public email provider shared as a domain, an unknown field, or neither `add` nor `remove` names anyone. Nothing is changed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The API key did not create this task, or the key is disabled or lacks permission. Only the API key that created the task can view or change who it is shared with.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "not_owner": {
                    "summary": "Key did not create the task",
                    "value": {
                      "error": "Only the task owner can share it",
                      "code": "task.not_owner"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "description": "Too many reports were shared in the last 24 hours. Nothing is changed. Try again later.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/v1/deepresearch/tasks/{id}/edit": {
      "post": {
        "operationId": "createDeepResearchEdit",
        "summary": "Edit a completed report or deliverable",
        "description": "Submit a small, targeted natural-language edit to a completed DeepResearch markdown report or one of its generated deliverable files. Edits apply exact replacements so untouched text stays byte-for-byte identical, and new citations only point to sources the task already gathered.\n\nSet `wait_seconds` (0 to 20) to wait inline: if the edit finishes in time, this endpoint returns `200` with the full edit record; otherwise it returns `202` and you poll [Get edit](https://docs.valyu.ai/api-reference/endpoint/deepresearch-edit-get). Send an `Idempotency-Key` header so retries return the same edit.\n\nOnly the task owner can submit edits. The task must be completed and must be a markdown report (not a structured JSON-schema output). Only one edit or restore runs at a time per task.",
        "tags": [
          "DeepResearch"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "DeepResearch task ID.",
            "example": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Optional idempotency key. Replaying the request with the same key returns the same edit instead of starting a duplicate.",
            "example": "7c9e6679-7425-40de-944b-e07fc1f90ae7"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeepResearchEditRequest"
              },
              "examples": {
                "report_section": {
                  "summary": "Edit a specific report section",
                  "value": {
                    "instruction": "Cut the executive summary to 3 bullets and add the Q3 revenue figure with its citation.",
                    "focus": {
                      "section": "Executive Summary",
                      "scope": "strict"
                    },
                    "base_version": 1,
                    "citations": "stable",
                    "wait_seconds": 15
                  }
                },
                "highlighted_passage": {
                  "summary": "Edit a highlighted passage with offsets and context",
                  "value": {
                    "instruction": "Add a caveat that margin guidance excludes pending acquisitions.",
                    "focus": {
                      "start_char": 1840,
                      "end_char": 1965,
                      "text": "Management expects operating margin to expand by 250 bps in FY2027.",
                      "prefix": "## Outlook\n\n",
                      "suffix": " Capital expenditure is projected to remain flat.",
                      "section": "Outlook",
                      "scope": "strict"
                    },
                    "base_version": 1
                  }
                },
                "deliverable": {
                  "summary": "Edit a generated deliverable file",
                  "value": {
                    "instruction": "Add a YoY growth % column to the Revenue Comparison sheet and format it with one decimal place.",
                    "target": {
                      "kind": "deliverable",
                      "deliverable_id": "f_01"
                    },
                    "base_version": 2,
                    "wait_seconds": 20
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Edit finished within `wait_seconds` (or replayed via `Idempotency-Key` after finishing). Check `status` (`applied`, `declined`, or `failed`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeepResearchEditRecord"
                },
                "examples": {
                  "applied": {
                    "summary": "Applied edit record",
                    "value": {
                      "edit_id": "ed_01j9x4k2m8n7p3q5r6s8t0v2w4",
                      "deepresearch_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                      "status": "applied",
                      "target": {
                        "kind": "report"
                      },
                      "base_version": 1,
                      "version": 2,
                      "focus": {
                        "section": "Executive Summary",
                        "scope": "strict"
                      },
                      "created_at": "2026-11-19T14:20:00.000Z",
                      "summary": "Condensed the Executive Summary to 3 bullets and added the Q3 revenue figure with citation [14].",
                      "changes": [
                        {
                          "section": "Executive Summary",
                          "description": "Replaced the 6-bullet summary with 3 bullets and added Q3 revenue cited to [14]."
                        }
                      ],
                      "unapplied": [],
                      "stats": {
                        "replacements": 1,
                        "chars_changed": 412,
                        "citations_added": 1
                      },
                      "warnings": [],
                      "pdf_url": "https://api.valyu.ai/v1/deepresearch/tasks/a1b2c3d4-e5f6-7890-abcd-ef1234567890/assets/report.pdf?version=2"
                    }
                  },
                  "declined": {
                    "summary": "Declined edit record",
                    "value": {
                      "edit_id": "ed_01j9x4m9a1b2c3d4e5f6g7h8j9",
                      "deepresearch_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                      "status": "declined",
                      "target": {
                        "kind": "report"
                      },
                      "base_version": 2,
                      "created_at": "2026-11-19T14:25:00.000Z",
                      "summary": "Could not add Q4 guidance because the task's gathered sources do not contain it.",
                      "changes": [],
                      "unapplied": [
                        "Add Q4 2026 guidance figures"
                      ],
                      "warnings": [],
                      "decline": {
                        "code": "edit.out_of_evidence",
                        "message": "The requested Q4 2026 guidance was not found in the sources gathered by this task.",
                        "suggestion": "Start a new DeepResearch task targeting Q4 2026 guidance."
                      }
                    }
                  }
                }
              }
            }
          },
          "202": {
            "description": "Edit accepted and still running. Poll `GET /v1/deepresearch/tasks/{id}/edits/{edit_id}` after `retry_after_seconds`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeepResearchEditAcceptedResponse"
                },
                "examples": {
                  "running": {
                    "summary": "Edit accepted and running",
                    "value": {
                      "edit_id": "ed_01j9x4k2m8n7p3q5r6s8t0v2w4",
                      "deepresearch_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                      "status": "running",
                      "target": {
                        "kind": "report"
                      },
                      "base_version": 1,
                      "focus": {
                        "section": "Executive Summary",
                        "scope": "strict"
                      },
                      "created_at": "2026-11-19T14:20:00.000Z",
                      "retry_after_seconds": 3
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request body, unknown JSON field, or invalid field values (`edit.invalid_request`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "invalid_request": {
                    "summary": "Invalid edit request",
                    "value": {
                      "error": "Unknown field 'extra' in request body",
                      "code": "edit.invalid_request"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Only the task owner can edit a task. Shared and public viewers receive `403`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Task not found, or report editing is not enabled.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict with current task state or version (`edit.task_not_completed`, `edit.in_progress`, `edit.revision_conflict`, or `edit.unsupported_task`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "revision_conflict": {
                    "summary": "Base version behind current head",
                    "value": {
                      "error": "Task is at version 2; base_version 1 is stale.",
                      "code": "edit.revision_conflict"
                    }
                  },
                  "in_progress": {
                    "summary": "Another edit or restore is already running",
                    "value": {
                      "error": "An edit is already in progress for this task.",
                      "code": "edit.in_progress"
                    }
                  },
                  "task_not_completed": {
                    "summary": "Task has not completed",
                    "value": {
                      "error": "Only completed tasks can be edited.",
                      "code": "edit.task_not_completed"
                    }
                  },
                  "unsupported_task": {
                    "summary": "Task output is not editable",
                    "value": {
                      "error": "Structured JSON-schema tasks cannot be edited.",
                      "code": "edit.unsupported_task"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Focus could not be matched (`focus.not_found`) or matched multiple places (`focus.ambiguous`, returning `candidates[]` to pick from). Nothing is run.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeepResearchFocusErrorResponse"
                },
                "examples": {
                  "not_found": {
                    "summary": "Focus text not found",
                    "value": {
                      "error": "Could not locate the focused passage in version 1.",
                      "code": "focus.not_found"
                    }
                  },
                  "ambiguous": {
                    "summary": "Focus text matched multiple locations",
                    "value": {
                      "error": "Focused text matched 2 locations. Pass offsets or prefix/suffix to disambiguate.",
                      "code": "focus.ambiguous",
                      "candidates": [
                        {
                          "start_char": 620,
                          "end_char": 655,
                          "section": "Executive Summary",
                          "prefix": "In Q3 2026, ",
                          "suffix": " across enterprise accounts."
                        },
                        {
                          "start_char": 4810,
                          "end_char": 4845,
                          "section": "Regional Breakdown",
                          "prefix": "In North America, ",
                          "suffix": " compared to the prior year."
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Edit capacity is temporarily busy (`edit.busy`). Retry later.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "busy": {
                    "summary": "Editor temporarily busy",
                    "value": {
                      "error": "Report editor is temporarily busy. Retry later.",
                      "code": "edit.busy"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/v1/deepresearch/tasks/{id}/edits": {
      "get": {
        "operationId": "listDeepResearchEdits",
        "summary": "List edits for a task",
        "description": "List edit records submitted for a DeepResearch task. Only the task owner can list edits.",
        "tags": [
          "DeepResearch"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "DeepResearch task ID.",
            "example": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "List of edit records for the task.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeepResearchEditListResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/v1/deepresearch/tasks/{id}/edits/{edit_id}": {
      "get": {
        "operationId": "getDeepResearchEdit",
        "summary": "Get an edit record",
        "description": "Retrieve the status and full record of a single DeepResearch edit. Poll this endpoint after `POST /v1/deepresearch/tasks/{id}/edit` returns `202` until `status` is `applied`, `declined`, or `failed`. Only the task owner can read edit records.",
        "tags": [
          "DeepResearch"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "DeepResearch task ID.",
            "example": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          },
          {
            "name": "edit_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Edit ID returned by `POST /v1/deepresearch/tasks/{id}/edit`.",
            "example": "ed_01j9x4k2m8n7p3q5r6s8t0v2w4"
          }
        ],
        "responses": {
          "200": {
            "description": "Edit record.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeepResearchEditRecord"
                },
                "examples": {
                  "applied_with_warning": {
                    "summary": "Applied report edit on a task with deliverables",
                    "value": {
                      "edit_id": "ed_01j9x4k2m8n7p3q5r6s8t0v2w4",
                      "deepresearch_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                      "status": "applied",
                      "target": {
                        "kind": "report"
                      },
                      "base_version": 1,
                      "version": 2,
                      "created_at": "2026-11-19T14:20:00.000Z",
                      "summary": "Tightened the executive summary to 3 bullets.",
                      "changes": [
                        {
                          "section": "Executive Summary",
                          "description": "Condensed 6 bullets to 3 bullets."
                        }
                      ],
                      "unapplied": [],
                      "stats": {
                        "replacements": 1,
                        "chars_changed": 318
                      },
                      "warnings": [
                        {
                          "type": "deliverables_stale",
                          "message": "Deliverable files were not updated to match this report edit."
                        }
                      ],
                      "pdf_url": "https://api.valyu.ai/v1/deepresearch/tasks/a1b2c3d4-e5f6-7890-abcd-ef1234567890/assets/report.pdf?version=2"
                    }
                  },
                  "interrupted": {
                    "summary": "Failed edit interrupted by restart",
                    "value": {
                      "edit_id": "ed_01j9x4p7q8r9s0t1u2v3w4x5y6",
                      "deepresearch_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                      "status": "failed",
                      "target": {
                        "kind": "report"
                      },
                      "base_version": 2,
                      "created_at": "2026-11-19T14:30:00.000Z",
                      "error": {
                        "code": "edit.interrupted",
                        "message": "The edit was interrupted before completion. Submit the edit again.",
                        "retryable": true
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/v1/deepresearch/tasks/{id}/versions": {
      "get": {
        "operationId": "listDeepResearchVersions",
        "summary": "List task versions",
        "description": "List all versions of a DeepResearch task (`original`, `edit`, and `restore`) along with the current `head` version number. Read a specific version's full output, sources, PDF, and files with `GET /v1/deepresearch/tasks/{id}/status?version=N`. Only the task owner can list versions.",
        "tags": [
          "DeepResearch"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "DeepResearch task ID.",
            "example": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "Version history for the task.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeepResearchVersionListResponse"
                },
                "examples": {
                  "history": {
                    "summary": "Task with original, edited, and restored versions",
                    "value": {
                      "deepresearch_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                      "head": 2,
                      "versions": [
                        {
                          "version": 2,
                          "kind": "edit",
                          "target": {
                            "kind": "report"
                          },
                          "created_at": "2026-11-19T14:20:09.000Z",
                          "edit_id": "ed_01j9x4k2m8n7p3q5r6s8t0v2w4",
                          "instruction": "Cut the executive summary to 3 bullets and add the Q3 revenue figure with its citation.",
                          "summary": "Condensed the Executive Summary to 3 bullets and added the Q3 revenue figure with citation [14].",
                          "stats": {
                            "replacements": 1,
                            "chars_changed": 412,
                            "citations_added": 1
                          },
                          "is_head": true,
                          "pdf_url": "https://api.valyu.ai/v1/deepresearch/tasks/a1b2c3d4-e5f6-7890-abcd-ef1234567890/assets/report.pdf?version=2"
                        },
                        {
                          "version": 1,
                          "kind": "original",
                          "target": {
                            "kind": "report"
                          },
                          "created_at": "2026-11-19T14:12:00.000Z",
                          "edit_id": null,
                          "instruction": null,
                          "summary": null,
                          "stats": null,
                          "is_head": false,
                          "pdf_url": "https://api.valyu.ai/v1/deepresearch/tasks/a1b2c3d4-e5f6-7890-abcd-ef1234567890/assets/report.pdf?version=1"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/v1/deepresearch/tasks/{id}/versions/{n}/restore": {
      "post": {
        "operationId": "restoreDeepResearchVersion",
        "summary": "Restore an earlier version",
        "description": "Synchronously restore a completed DeepResearch task to a previous version `n` with no model call. Creates a new head version equal to version `n`; version history is never deleted. Only the task owner can restore versions, and only one edit or restore can run at a time per task.",
        "tags": [
          "DeepResearch"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "DeepResearch task ID.",
            "example": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          },
          {
            "name": "n",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            },
            "description": "Version number to restore.",
            "example": 1
          }
        ],
        "responses": {
          "200": {
            "description": "Version restored as a new head version.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeepResearchVersionRestoreResponse"
                },
                "examples": {
                  "restored": {
                    "summary": "Restored version 1 as version 3",
                    "value": {
                      "version": 3,
                      "restored_from": 1
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid version number (`edit.invalid_request`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "Another edit or restore is already running (`edit.in_progress`), or the task cannot be edited (`edit.task_not_completed`, `edit.unsupported_task`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/v1/deepresearch/tasks/{id}/respond": {
      "post": {
        "operationId": "respondToDeepResearch",
        "summary": "Respond to a HITL checkpoint",
        "description": "Respond to a human-in-the-loop checkpoint. The task must be in `awaiting_input` or `paused` status. Pass the `interaction_id` from the task's `interaction` field along with the response data matching the checkpoint type.\n\nA `paused` task needs enough balance to cover its mode price when it resumes. If the balance no longer covers it, the task ends as `failed` and is not charged.",
        "tags": [
          "DeepResearch"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "DeepResearch task ID."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["interaction_id", "response"],
                "properties": {
                  "interaction_id": {
                    "type": "string",
                    "description": "The interaction_id from the task's interaction field."
                  },
                  "response": {
                    "description": "Response data - shape depends on the checkpoint type (`interaction.type`).",
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/HitlPlanningQuestionsResponse"
                      },
                      {
                        "$ref": "#/components/schemas/HitlPlanReviewResponse"
                      },
                      {
                        "$ref": "#/components/schemas/HitlSourceReviewResponse"
                      },
                      {
                        "$ref": "#/components/schemas/HitlOutlineReviewResponse"
                      }
                    ]
                  }
                }
              },
              "examples": {
                "Planning Questions": {
                  "summary": "Answer planning questions",
                  "value": {
                    "interaction_id": "int_abc123",
                    "response": {
                      "answers": [
                        {"question": "What geographic regions?", "answer": "North America and EU"},
                        {"question": "Specific competitors?", "answer": "Tesla, BYD, Rivian"}
                      ]
                    }
                  }
                },
                "Plan Review": {
                  "summary": "Approve research plan",
                  "value": {
                    "interaction_id": "int_abc123",
                    "response": {
                      "approved": true
                    }
                  }
                },
                "Source Review": {
                  "summary": "Filter sources by domain",
                  "value": {
                    "interaction_id": "int_abc123",
                    "response": {
                      "included_domains": ["sec.gov", "plos.org"],
                      "excluded_domains": ["example.com"]
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Response accepted. Task resumes processing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "status": {
                      "type": "string",
                      "description": "`running` if container was still alive, `queued` if task was re-enqueued from paused state.",
                      "enum": ["running", "queued"],
                      "example": "running"
                    },
                    "deepresearch_id": {
                      "type": "string",
                      "example": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error in response data.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "response.answers must be an array"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "The task is not in `awaiting_input` or `paused` status, the `interaction_id` does not match, or the task was cancelled while it was being resumed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "Cannot respond to task with status: running. Task must be in 'awaiting_input' or 'paused' status."
                    }
                  }
                },
                "examples": {
                  "wrong_status": {
                    "summary": "Task not waiting for input",
                    "value": {
                      "error": "Cannot respond to task with status: running. Task must be in 'awaiting_input' or 'paused' status."
                    }
                  },
                  "no_longer_paused": {
                    "summary": "Task cancelled during resume",
                    "value": {
                      "error": "Task is no longer paused."
                    }
                  }
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/v1/deepresearch/batches": {
      "post": {
        "operationId": "createBatch",
        "summary": "Create a new batch",
        "description": "Create a batch for running multiple DeepResearch tasks with shared configuration. After creation, add tasks with the Add Tasks endpoint. The batch transitions from `open` to `processing` when tasks are added.",
        "tags": [
          "Batches"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateBatchRequest"
              },
              "examples": {
                "example": {
                  "summary": "Create a batch for earnings analysis",
                  "value": {
                    "name": "Q4 2024 Earnings Analysis",
                    "mode": "standard",
                    "output_formats": [
                      "markdown",
                      "pdf"
                    ],
                    "search": {
                      "search_type": "proprietary",
                      "included_sources": [
                        "finance"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Batch created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchResponse"
                },
                "examples": {
                  "example": {
                    "summary": "Batch created successfully",
                    "value": {
                      "batch_id": "batch_a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                      "status": "open",
                      "mode": "standard",
                      "name": "Q4 2024 Earnings Analysis",
                      "output_formats": [
                        "markdown",
                        "pdf"
                      ],
                      "search_params": {
                        "search_type": "proprietary",
                        "included_sources": [
                          "finance"
                        ]
                      },
                      "counts": {
                        "total": 0,
                        "queued": 0,
                        "running": 0,
                        "completed": 0,
                        "failed": 0,
                        "cancelled": 0
                      },
                      "cost": 0,
                      "created_at": "2024-06-15T10:30:00.000Z",
                      "webhook_secret": "EXAMPLE_WEBHOOK_SECRET_REPLACE_WITH_RETURNED_VALUE"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "description": "The account can't pay for new research, so the batch was not created. Nothing is charged. DeepResearch error bodies have `error` (and `code` for budget caps) but no `success` field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "no_balance": {
                    "summary": "Balance exhausted",
                    "value": {
                      "error": "Insufficient credits. Please top up your account."
                    }
                  },
                  "spend_cap": {
                    "summary": "API key budget cap reached",
                    "value": {
                      "error": "API key budget cap reached. Raise the key's credit cap or use an uncapped key.",
                      "code": "spend_cap_reached"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      },
      "get": {
        "operationId": "listBatches",
        "summary": "List all batches",
        "description": "Retrieve all batches for the authenticated API key.",
        "tags": [
          "Batches"
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            },
            "description": "Maximum number of batches to return, from 1 to 100. Send `limit` in every request. Without it, the API returns every batch. This default is deprecated. A later version will return 20 batches."
          }
        ],
        "responses": {
          "200": {
            "description": "List of batches.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/BatchResponse"
                  }
                },
                "examples": {
                  "success": {
                    "summary": "List of batches",
                    "value": [
                      {
                        "batch_id": "batch_a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                        "status": "completed",
                        "mode": "standard",
                        "created_at": "2024-06-15T10:30:00.000Z",
                        "counts": {
                          "total": 5,
                          "queued": 0,
                          "running": 0,
                          "completed": 5,
                          "failed": 0,
                          "cancelled": 0
                        },
                        "cost": 3.125
                      }
                    ]
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/v1/deepresearch/batches/{id}": {
      "get": {
        "operationId": "getBatchStatus",
        "summary": "Get batch status",
        "description": "Retrieve the current status, task counts, and aggregated cost of a batch.",
        "tags": [
          "Batches"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Batch ID.",
            "example": "batch_a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "Batch status.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchResponse"
                },
                "examples": {
                  "success": {
                    "summary": "Batch status with counts",
                    "value": {
                      "batch_id": "batch_a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                      "status": "processing",
                      "mode": "standard",
                      "created_at": "2024-06-15T10:30:00.000Z",
                      "counts": {
                        "total": 10,
                        "queued": 2,
                        "running": 3,
                        "completed": 4,
                        "failed": 1,
                        "cancelled": 0
                      },
                      "cost": 2.5
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/v1/deepresearch/batches/{id}/tasks": {
      "post": {
        "operationId": "addBatchTasks",
        "summary": "Add tasks to a batch",
        "description": "Add up to 100 research tasks to an existing batch. The batch must be in `open` or `processing` status.\n\n**Billing.** The mode price for every task in the request is held against your balance in one all-or-nothing step. If the balance (minus amounts held for your other tasks) can't cover all of them, or the monthly usage limit would be exceeded, the request returns 402 and no tasks are added. If billing can't be checked, it returns 503 and nothing is added. A task that waits in the queue for more than 48 hours needs balance again when it starts; if the balance no longer covers it, the task ends as `failed` and is not charged.",
        "tags": [
          "Batches"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Batch ID."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddBatchTasksRequest"
              },
              "examples": {
                "example": {
                  "summary": "Add earnings analysis tasks",
                  "value": {
                    "tasks": [
                      {
                        "query": "Analyze Tesla Q4 2024 earnings and forward guidance",
                        "id": "task-tesla"
                      },
                      {
                        "query": "Analyze Apple Q4 2024 earnings and iPhone sales",
                        "id": "task-apple"
                      },
                      {
                        "query": "Analyze Microsoft Q4 2024 earnings and Azure growth",
                        "id": "task-msft"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Tasks added and queued.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AddBatchTasksResponse"
                }
              }
            }
          },
          "400": {
            "description": "Batch is not accepting tasks (not open or processing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "description": "The tasks can't be paid for, so none were added. Nothing is charged. DeepResearch error bodies have no `success` field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "insufficient": {
                    "summary": "Balance does not cover every task",
                    "value": {
                      "error": "Insufficient credits for 3 tasks."
                    }
                  },
                  "limit": {
                    "summary": "Monthly usage limit would be exceeded",
                    "value": {
                      "error": "Monthly credit limit would be exceeded by this batch. Please increase your limits."
                    }
                  },
                  "spend_cap": {
                    "summary": "API key budget cap reached",
                    "value": {
                      "error": "API key budget cap reached. Raise the key's credit cap or use an uncapped key.",
                      "code": "spend_cap_reached"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      },
      "get": {
        "operationId": "listBatchTasks",
        "summary": "List tasks in a batch",
        "description": "Retrieve tasks within a batch with optional status filtering and cursor-based pagination. Use `include_output=true` to get full output, sources, images, and cost for each task. When `include_output` is false (default), returns a lightweight listing with status only.",
        "tags": [
          "Batches"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Batch ID."
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "queued",
                "running",
                "completed",
                "failed",
                "cancelled"
              ]
            },
            "description": "Filter tasks by status."
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1
            },
            "description": "Maximum number of tasks to return."
          },
          {
            "name": "last_key",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "nullable": true
            },
            "description": "Pagination cursor. Omit on first request. Pass the `last_key` value from a previous response to fetch the next page."
          },
          {
            "name": "include_output",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            },
            "example": true,
            "description": "Include full output, sources, images, and cost for each task. When false (default), returns lightweight task listing with status only."
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated list of batch tasks.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchTaskListResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/v1/deepresearch/batches/{id}/cancel": {
      "post": {
        "operationId": "cancelBatch",
        "summary": "Cancel a batch",
        "description": "Cancel all queued and running tasks in a batch. The batch must be in `open` or `processing` status.",
        "tags": [
          "Batches"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Batch ID."
          }
        ],
        "responses": {
          "200": {
            "description": "Batch cancelled.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CancelBatchResponse"
                },
                "examples": {
                  "success": {
                    "summary": "Batch cancelled",
                    "value": {
                      "batch_id": "batch_a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                      "status": "cancelled",
                      "cancelled_count": 3
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Batch cannot be cancelled (not open or processing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/v1/datasources": {
      "get": {
        "operationId": "listDatasources",
        "summary": "List available data sources",
        "description": "Discover all data sources available through Valyu's search API. Each datasource includes metadata, example queries (optimized for few-shot prompting), pricing information, and response schemas.\n\nUse this endpoint to build dynamic tool manifests for AI agents instead of hardcoding knowledge of available datasets.",
        "tags": [
          "Datasources"
        ],
        "parameters": [
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter datasources by category. Use the categories endpoint to discover available categories.",
            "example": "research"
          }
        ],
        "responses": {
          "200": {
            "description": "List of available datasources.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DatasourcesResponse"
                },
                "examples": {
                  "example": {
                    "summary": "Illustrative catalog subset; consult the endpoint for current coverage",
                    "value": {
                      "success": true,
                      "datasources": [
                        {
                          "id": "valyu/valyu-arxiv",
                          "name": "arXiv",
                          "description": "Preprints in physics, mathematics, computer science, quantitative biology, and more.",
                          "category": "research",
                          "topics": [
                            "physics",
                            "mathematics",
                            "computer science"
                          ],
                          "modality": [
                            "text",
                            "images"
                          ],
                          "example_queries": [
                            "CRISPR gene editing mechanisms",
                            "quantum error correction methods"
                          ],
                          "pricing": {
                            "cpm": 0.3125
                          },
                          "update_frequency": "Monthly",
                          "size": 1000000
                        },
                        {
                          "id": "valyu/valyu-pubmed",
                          "name": "PubMed",
                          "description": "Biomedical literature from MEDLINE, life science journals, and online books.",
                          "category": "healthcare",
                          "topics": [
                            "medicine",
                            "biology",
                            "pharmacology"
                          ],
                          "modality": [
                            "text",
                            "images"
                          ],
                          "example_queries": [
                            "GLP-1 receptor agonists for type 2 diabetes",
                            "CAR-T cell therapy advances"
                          ],
                          "pricing": {
                            "cpm": 0.3125
                          },
                          "update_frequency": "Monthly",
                          "size": 2500000
                        }
                      ],
                      "total_count": 2
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Unknown `category`. List valid values with `GET /v1/datasources/categories`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "unknown_category": {
                    "summary": "Unknown category",
                    "value": {
                      "success": false,
                      "error": "Invalid category 'sports'. Valid categories: company, economic, healthcare, legal, markets, patents, politics, predictions, research, transportation"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The API key does not have permission to read the catalogue.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "permission": {
                    "summary": "Key lacks permission",
                    "value": {
                      "success": false,
                      "error": "API key does not have inference permission"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/v1/datasources/categories": {
      "get": {
        "operationId": "listDatasourceCategories",
        "summary": "List datasource categories",
        "description": "Retrieve all available datasource categories. Use these to filter the datasources endpoint.\n\nCategories include: `research`, `healthcare`, `markets`, `company`, `economic`, `predictions`, `transportation`, `legal`, `politics`, `patents`.",
        "tags": [
          "Datasources"
        ],
        "responses": {
          "200": {
            "description": "List of datasource categories.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DatasourceCategoriesResponse"
                },
                "examples": {
                  "example": {
                    "summary": "All categories",
                    "value": {
                      "success": true,
                      "categories": [
                        {
                          "id": "research",
                          "name": "Research",
                          "description": "Academic papers, preprints, and scholarly articles.",
                          "dataset_count": 8
                        },
                        {
                          "id": "healthcare",
                          "name": "Healthcare",
                          "description": "Medical literature, clinical trials, drug data, and health records.",
                          "dataset_count": 6
                        },
                        {
                          "id": "markets",
                          "name": "Markets",
                          "description": "Stock prices, earnings, SEC filings, and financial data.",
                          "dataset_count": 5
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The API key does not have permission to read the catalogue.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "permission": {
                    "summary": "Key lacks permission",
                    "value": {
                      "success": false,
                      "error": "API key does not have inference permission"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/v1/datasources/search": {
      "get": {
        "operationId": "searchDatasources",
        "summary": "Search datasources",
        "description": "Find datasets by describing what you need in natural language, e.g. `Wiley medical literature`, `FDA drug labels`, `insider transactions`, `CPI inflation`. Ranking is semantic (embedding similarity) blended with exact-term matching, so both descriptive phrases and terse acronyms work.\n\nUse the returned `id` values as `included_sources` on the Search API. Results are ranked best-first with a `relevance_score` in the range 0-1; a query matching nothing in the catalog returns an empty list rather than a weak guess.\n\nOnly datasets your key can search are returned (the same visibility rules as `GET /v1/datasources`).",
        "tags": [
          "Datasources"
        ],
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Natural-language description of the data you want. `query` is accepted as an alias.",
            "example": "clinical trial results"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            },
            "description": "Maximum number of datasets to return. Values above 100 are capped at 100."
          }
        ],
        "responses": {
          "200": {
            "description": "Ranked datasets matching the query.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DatasourceSearchResponse"
                },
                "examples": {
                  "example": {
                    "summary": "FDA drug label",
                    "value": {
                      "success": true,
                      "query": "FDA drug label",
                      "search_mode": "semantic",
                      "total_count": 3,
                      "results": [
                        {
                          "id": "valyu/valyu-drug-labels",
                          "name": "FDA Drug Labels",
                          "category": "healthcare",
                          "relevance_score": 0.7969,
                          "description": "Medication label records."
                        },
                        {
                          "id": "valyu/valyu-openfda-drug-events",
                          "name": "openFDA Drug Adverse Events",
                          "category": "healthcare",
                          "relevance_score": 0.3927,
                          "description": "Reported drug adverse events."
                        },
                        {
                          "id": "valyu/valyu-pubchem",
                          "name": "PubChem",
                          "category": "healthcare",
                          "relevance_score": 0.2539,
                          "description": "Chemical compound records."
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing `q` parameter."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The API key does not have permission to read the catalogue.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "permission": {
                    "summary": "Key lacks permission",
                    "value": {
                      "success": false,
                      "error": "API key does not have inference permission"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/v1/workflows": {
      "get": {
        "operationId": "listWorkflows",
        "summary": "List workflows (Beta)",
        "description": "**Beta.** List workflows visible to your organization. Includes both your org's private workflows and curated Valyu workflows. Run a workflow by passing its `slug` as `workflow_id` to `POST /v1/deepresearch/tasks`.",
        "tags": [
          "Workflows"
        ],
        "parameters": [
          {
            "name": "vertical",
            "in": "query",
            "required": false,
            "schema": { "type": "string" },
            "description": "Filter by vertical (e.g. `finance`, `life-sciences`).",
            "example": "finance"
          },
          {
            "name": "scope",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["valyu", "org", "all"],
              "default": "all"
            },
            "description": "Which workflows to return: `valyu` (curated only), `org` (your org only), or `all` (both, default)."
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": { "type": "string" },
            "description": "Free-text search across title, subtitle, and description.",
            "example": "diligence"
          },
          {
            "name": "tags",
            "in": "query",
            "required": false,
            "schema": { "type": "string" },
            "description": "Comma-separated tags to filter by.",
            "example": "earnings,equities"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            },
            "description": "Maximum number of workflows to return (max 100)."
          },
          {
            "name": "expand",
            "in": "query",
            "required": false,
            "schema": { "type": "string" },
            "description": "Comma-separated list of fields to expand. Pass `version` to include the full current version row for each workflow.",
            "example": "version"
          }
        ],
        "responses": {
          "200": {
            "description": "List of workflows.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowListResponse"
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      },
      "post": {
        "operationId": "createWorkflow",
        "summary": "Create an organization workflow (Beta)",
        "description": "**Beta.** Create a private workflow owned by your organization. Subject to your org's workflow quota (default 100). Returns `409 workflow_quota_exceeded` when the quota is reached.",
        "tags": [
          "Workflows"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WorkflowCreateRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Workflow created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowResponse"
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/WorkflowBadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "409": { "$ref": "#/components/responses/WorkflowConflict" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/v1/workflows/{slug}": {
      "get": {
        "operationId": "getWorkflow",
        "summary": "Get a workflow (Beta)",
        "description": "**Beta.** Retrieve a single workflow with its resolved version. By default returns the current version; pass `version` to fetch a specific one.",
        "tags": [
          "Workflows"
        ],
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": { "type": "string" },
            "description": "The workflow slug.",
            "example": "ib-company-profile"
          },
          {
            "name": "version",
            "in": "query",
            "required": false,
            "schema": { "type": "integer", "minimum": 1 },
            "description": "Version to return. Defaults to the current version.",
            "example": 3
          }
        ],
        "responses": {
          "200": {
            "description": "The workflow.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowResponse"
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "404": { "$ref": "#/components/responses/WorkflowNotFound" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      },
      "patch": {
        "operationId": "updateWorkflow",
        "summary": "Edit a workflow / publish a new version (Beta)",
        "description": "**Beta.** Edit an organization workflow, publishing a new immutable version. A `changelog` is required (`changelog_required` otherwise). Valyu-curated workflows are read-only and return `403 cannot_edit_valyu_workflow`.",
        "tags": [
          "Workflows"
        ],
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": { "type": "string" },
            "description": "The workflow slug.",
            "example": "ib-company-profile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WorkflowUpdateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "New version published.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowResponse"
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/WorkflowBadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/WorkflowForbidden" },
          "404": { "$ref": "#/components/responses/WorkflowNotFound" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      },
      "delete": {
        "operationId": "deleteWorkflow",
        "summary": "Delete a workflow (Beta)",
        "description": "**Beta.** Soft-delete an organization workflow. Valyu-curated workflows cannot be deleted and return `403 cannot_delete_valyu_workflow`.",
        "tags": [
          "Workflows"
        ],
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": { "type": "string" },
            "description": "The workflow slug.",
            "example": "ib-company-profile"
          }
        ],
        "responses": {
          "200": {
            "description": "Workflow deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowDeleteResponse"
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/WorkflowForbidden" },
          "404": { "$ref": "#/components/responses/WorkflowNotFound" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/v1/workflows/{slug}/versions": {
      "get": {
        "operationId": "listWorkflowVersions",
        "summary": "List workflow versions (Beta)",
        "description": "**Beta.** List all immutable versions of a workflow, newest first.",
        "tags": [
          "Workflows"
        ],
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": { "type": "string" },
            "description": "The workflow slug.",
            "example": "ib-company-profile"
          }
        ],
        "responses": {
          "200": {
            "description": "List of versions.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowVersionListResponse"
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "404": { "$ref": "#/components/responses/WorkflowNotFound" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/v1/workflows/{slug}/versions/{n}": {
      "get": {
        "operationId": "getWorkflowVersion",
        "summary": "Get a specific workflow version (Beta)",
        "description": "**Beta.** Retrieve a workflow resolved at a specific immutable version. Returns the same flat workflow object as `GET /v1/workflows/{slug}?version={n}`.",
        "tags": [
          "Workflows"
        ],
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": { "type": "string" },
            "description": "The workflow slug.",
            "example": "ib-company-profile"
          },
          {
            "name": "n",
            "in": "path",
            "required": true,
            "schema": { "type": "integer", "minimum": 1 },
            "description": "The version number.",
            "example": 2
          }
        ],
        "responses": {
          "200": {
            "description": "The workflow resolved at the requested version.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowResponse"
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "404": { "$ref": "#/components/responses/WorkflowNotFound" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/v1/workflows/{slug}/preview": {
      "post": {
        "operationId": "previewWorkflow",
        "summary": "Preview a resolved workflow (Beta)",
        "description": "**Beta.** Resolve a workflow's prompt template against supplied `workflow_params` without running it. Returns the resolved prompt, research strategy, report format, deliverables, recommended mode, and tools - exactly what a run would use. Useful for validating parameters before incurring a DeepResearch cost.",
        "tags": [
          "Workflows"
        ],
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": { "type": "string" },
            "description": "The workflow slug.",
            "example": "ib-company-profile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WorkflowPreviewRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Resolved configuration.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowPreviewResponse"
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/WorkflowBadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "404": { "$ref": "#/components/responses/WorkflowNotFound" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    }
  },
  "externalDocs": {
    "description": "Complete API Documentation",
    "url": "https://docs.valyu.ai"
  },
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "API key for authentication. Get yours at [platform.valyu.ai](https://platform.valyu.ai)."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "description": "Error response. Every error body has `error`. Search, Contents, Answer and Datasources errors usually also carry `success: false`. Errors returned before a request reaches the endpoint (missing, invalid or disabled keys, rate limits) and DeepResearch errors have no `success` field. Some errors add a machine-readable `code` and a `recovery` object.",
        "required": [
          "error"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "description": "`false` when present.",
            "example": false
          },
          "error": {
            "type": "string",
            "description": "Error message, or a machine-readable code for some errors (for example `invalid_scope_policy`, or `rate_limited` on a `429`).",
            "example": "Invalid request parameters"
          },
          "message": {
            "type": "string",
            "description": "Human-readable detail. Present on errors returned before the request reaches the endpoint."
          },
          "code": {
            "type": "string",
            "description": "Stable machine-readable error code, when available. Branch on this rather than on the message text.",
            "example": "insufficient_credits"
          },
          "recovery": {
            "type": "object",
            "description": "Links or details that help resolve the error, when available.",
            "additionalProperties": true
          },
          "transaction_id": {
            "type": "string",
            "description": "Transaction ID for support, when available."
          }
        }
      },
      "Warning": {
        "type": "object",
        "description": "Something the request skipped or adjusted. A warning means the request succeeded. New `type` values may be added at any time, so handle unknown ones by showing `message`. See [Warnings](https://docs.valyu.ai/api-reference/warnings).",
        "required": [
          "type",
          "message"
        ],
        "properties": {
          "type": {
            "type": "string",
            "description": "Stable snake_case warning type, for example `datasets_not_in_plan`. New types may be added at any time.",
            "example": "datasets_not_in_plan"
          },
          "message": {
            "type": "string",
            "description": "Self-contained sentence, safe to show a user or for an agent to relay as-is.",
            "example": "Your Pay-as-you-go plan doesn't include valyu/valyu-chemrxiv (Comfortably Pro, $99/mo), so it was skipped. Results come from your other sources. Comfortably Pro ($99/mo) includes it: https://platform.valyu.ai/user/account/billing?tab=plan"
          },
          "detail": {
            "type": "object",
            "nullable": true,
            "description": "Optional type-specific structured fields, including any URLs.",
            "additionalProperties": true,
            "example": {
              "datasets": [
                {
                  "id": "valyu/valyu-chemrxiv",
                  "required_plan": "tier_2"
                }
              ],
              "current_plan": "tier_0",
              "required_plan": {
                "id": "tier_2",
                "name": "Comfortably Pro",
                "price": "$99/mo"
              },
              "upgrade_url": "https://platform.valyu.ai/user/account/billing?tab=plan"
            }
          }
        }
      },
      "SearchRequest": {
        "type": "object",
        "required": [
          "query"
        ],
        "additionalProperties": false,
        "description": "Search request parameters.",
        "properties": {
          "query": {
            "type": "string",
            "description": "The search query to execute. Supports natural language queries.",
            "example": "latest developments in quantum computing"
          },
          "max_num_results": {
            "type": "integer",
            "description": "Maximum number of results to return. Higher limits (up to 100) are available on request. A value above your limit is lowered to it, and the response carries a `max_num_results_capped` warning.",
            "default": 5,
            "minimum": 1,
            "maximum": 20,
            "example": 10
          },
          "search_type": {
            "type": "string",
            "description": "Controls which data sources are searched.\n\n- `all` - Web and proprietary sources (default). An LLM router selects the best sources for your query.\n- `web` - Web search only. Best for current events and general topics.\n- `proprietary` - Academic, financial, and premium sources only. Best for research and technical analysis.\n- `news` - News articles only. Best for recent news and current events.",
            "enum": [
              "all",
              "web",
              "proprietary",
              "news"
            ],
            "default": "all",
            "example": "all"
          },
          "max_price": {
            "type": "number",
            "description": "Caps the cost of the whole request. This is not a token limit or a per-result ceiling. When omitted, the default is 1000. See [pricing](https://docs.valyu.ai/pricing).\n\nBefore searching, the request is checked against its worst-case cost and rejected with 400 (`Insufficient max_price. Search requires max_price >= X for your query`) if the budget is too low. For example, 10 web results need `max_price >= 6.25`.",
            "minimum": 0,
            "exclusiveMinimum": true,
            "example": 20.0
          },
          "relevance_threshold": {
            "type": "number",
            "description": "Minimum relevance score (0.0-1.0) for results after reranking. Results below this threshold are filtered out.",
            "default": 0.5,
            "minimum": 0.0,
            "maximum": 1.0,
            "example": 0.5
          },
          "included_sources": {
            "type": "array",
            "description": "Sources to include in the search. Accepts:\n- Domain names or URLs for web filtering (e.g. `\"arxiv.org\"`, `\"https://arxiv.org\"`)\n- Dataset identifiers for proprietary sources (e.g. `\"valyu/valyu-arxiv\"`)\n- Preset names that expand to curated source groups: `\"academic\"`, `\"finance\"`, `\"patent\"`, `\"transportation\"`, `\"politics\"`, `\"legal\"`, `\"health\"`, `\"genomics\"`, `\"chemistry\"`, `\"physics\"`\n- `\"web\"` keyword to explicitly include web search alongside proprietary sources\n- `\"collection:NAME\"` to reference an org-scoped saved source collection\n\nWith the default `scope_policy: \"advisory\"`, a list of two or more dataset IDs is treated as guidance: Valyu may search only the most relevant of them for the query. Set `scope_policy: \"strict\"` to search every listed dataset.\n\nDatasets above your plan are dropped; if none remain, the request returns 403 `tier_insufficient`. DeepResearch-only datasets are dropped when listed alongside other sources, and return 403 when they are the only sources requested.\n\nNote: most specialised and proprietary sources require a subscription. All plans include web search and open academic sources (arXiv, PubMed).",
            "items": {
              "type": "string"
            },
            "example": [
              "valyu/valyu-arxiv",
              "valyu/valyu-pubmed"
            ]
          },
          "excluded_sources": {
            "type": "array",
            "description": "Sources to exclude from the search. Accepts domain names, URLs, dataset identifiers and preset names (e.g. `\"finance\"`, `\"academic\"`). Excluded datasets and presets are never searched. With `scope_policy: \"strict\"`, only dataset identifiers are accepted, and they are removed from the `included_sources` list.",
            "items": {
              "type": "string"
            },
            "example": [
              "reddit.com"
            ]
          },
          "scope_policy": {
            "type": "string",
            "enum": [
              "advisory",
              "strict"
            ],
            "default": "advisory",
            "description": "How `included_sources` is applied to datasets.\n\n- `advisory` (default) - `included_sources` guides source selection. With two or more dataset IDs, Valyu may search only the most relevant of them.\n- `strict` - search exactly the dataset IDs in `included_sources`, minus any in `excluded_sources`. Requires 1-128 dataset IDs. Presets, domains, URLs, `\"web\"` and `search_type: \"web\"` are rejected, and web search is skipped. The response includes a `source_scope` receipt.\n\nStrict errors: 400 `invalid_scope_policy` (unknown value), 400 `invalid_strict_source_scope` (missing, empty or oversized list, a non-dataset entry, or nothing left after exclusions), 400 `unsupported_strict_source` (a dataset Search cannot serve), and 403 `dataset_outside_task_scope` (a dataset outside your plan or grants; no partial fallback).\n\nNot yet in the Python or TypeScript SDKs. Send it in the request body over HTTP.",
            "example": "strict"
          },
          "source_biases": {
            "type": "object",
            "description": "Bias values for specific sources to influence ranking without hard filtering. Keys are domains (e.g., 'nasa.gov') or URL paths (e.g., 'nih.gov/research'). Values are integers from -5 (strong demotion) to +5 (strong boost). Most specific path match wins.",
            "additionalProperties": {
              "type": "integer",
              "minimum": -5,
              "maximum": 5
            },
            "nullable": true,
            "example": {
              "nasa.gov": 5,
              "noaa.gov": 3,
              "nih.gov": 1,
              "example.com": -4
            }
          },
          "instructions": {
            "type": "string",
            "description": "Natural language instructions to help rank results by relevance to user intent. Acts as a system prompt for the search. Max 500 characters. Ignored when fast_mode is true.",
            "maxLength": 500,
            "example": "Focus on oncology clinical trials from 2023 onwards"
          },
          "category": {
            "type": "string",
            "deprecated": true,
            "description": "**Deprecated.** Use `instructions` instead. Falls back to this value if `instructions` is not set.",
            "maxLength": 500
          },
          "is_tool_call": {
            "type": "boolean",
            "description": "Indicates whether this request originates from an AI tool call. Affects query rewriting behavior.",
            "default": true
          },
          "response_length": {
            "description": "Controls the maximum character length of content per result.\n\n- `\"short\"` - 25,000 characters (default)\n- `\"medium\"` - 50,000 characters\n- `\"large\"` - 100,000 characters\n- `\"max\"` - No limit\n- Any positive integer for a custom character limit",
            "oneOf": [
              {
                "type": "string",
                "enum": [
                  "short",
                  "medium",
                  "large",
                  "max"
                ]
              },
              {
                "type": "integer",
                "minimum": 1
              }
            ],
            "default": "short",
            "example": "short"
          },
          "start_date": {
            "type": "string",
            "description": "Filter results published on or after this date. Accepts `YYYY`, `YYYY-MM-DD` or an ISO-8601 datetime. Sub-day timestamps require `historical_cache: true`. If set without `end_date`, `end_date` defaults to today.",
            "example": "2024-01-01"
          },
          "end_date": {
            "type": "string",
            "description": "Filter results published on or before this date. Accepts `YYYY`, `YYYY-MM-DD` or an ISO-8601 datetime. Sub-day timestamps require `historical_cache: true`. If set without `start_date`, `start_date` defaults to `1900-01-01`. `start_date` must be on or before `end_date`.",
            "example": "2024-12-31"
          },
          "country_code": {
            "type": "string",
            "description": "ISO 3166-1 alpha-2 country code for geo-targeted web search results.",
            "enum": [
              "ALL",
              "AR",
              "AU",
              "AT",
              "BE",
              "BR",
              "CA",
              "CL",
              "DK",
              "FI",
              "FR",
              "DE",
              "HK",
              "IN",
              "ID",
              "IT",
              "JP",
              "KR",
              "MY",
              "MX",
              "NL",
              "NZ",
              "NO",
              "CN",
              "PL",
              "PT",
              "PH",
              "RU",
              "SA",
              "ZA",
              "ES",
              "SE",
              "CH",
              "TW",
              "TR",
              "GB",
              "US"
            ],
            "example": "US"
          },
          "fast_mode": {
            "type": "boolean",
            "description": "Skip query rewriting and reranking for lower latency. Searches the web and financial data in parallel. Cannot be used with `search_type: \"proprietary\"`.",
            "default": false
          },
          "url_only": {
            "type": "boolean",
            "description": "Return only URLs without full content extraction. Only available when `search_type` is `\"web\"` or `\"news\"`. Skips reranking.",
            "default": false
          },
          "historical_cache": {
            "type": "boolean",
            "description": "Prefer cached content captured within the requested date window instead of the latest crawl. Requires a date range. With the default historical_cache_strict=\"prefer\", a result can fall back to a live crawl when no suitable snapshot exists. Use \"only\" to drop results without a qualifying snapshot; neither mode guarantees complete historical coverage or reproduces an entire past search index.",
            "default": false
          },
          "historical_cache_strict": {
            "type": "string",
            "enum": ["off", "prefer", "only"],
            "description": "Snapshot policy when historical_cache is true. \"prefer\" uses an in-window snapshot when available and otherwise may fall back to a live crawl. \"only\" drops results without a snapshot captured at or before the end-date cutoff. \"off\" disables strict snapshot filtering. Empty results are possible in every mode. For backtests, inspect record dates and snapshot evidence; publication-date filters alone do not establish point-in-time validity.",
            "default": "prefer"
          },
          "include_abstracts": {
            "type": "boolean",
            "description": "Expand PubMed search from papers with available full text to the complete abstract corpus. Results include the abstract and, when full text is available, the most relevant full-text chunks. Has no effect on other sources.",
            "default": false
          },
          "include_image_links": {
            "type": "boolean",
            "description": "Keep image URLs in the content. When `true` (default), images stay as markdown, for example `![Product photo](https://example.com/p.jpg)`. When `false`, each image becomes `[Image: Product photo]`. The API removes the image URL and keeps the alt text. The API removes an image with no alt text. A linked image `[![alt](src)](href)` becomes `[[Image: alt]](href)`. Other links do not change. Set `false` to use fewer tokens.",
            "default": true
          },
          "hls_coverage": {
            "type": "string",
            "enum": [
              "hls",
              "increased_coverage"
            ],
            "default": "hls",
            "description": "Coverage for Wiley Health & Life Sciences (`wiley/wiley-hls`) searches. `hls` returns licensed Wiley content only. `increased_coverage` blends it with open-access biomedical literature in one ranked result set. See [Wiley HLS](https://docs.valyu.ai/guides/wiley-hls).",
            "example": "hls"
          }
        }
      },
      "SearchResult": {
        "type": "object",
        "description": "A single search result with extracted content.",
        "required": [
          "id",
          "title",
          "url",
          "content",
          "source",
          "price",
          "length",
          "data_type",
          "source_type"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique identifier for this result (typically the URL).",
            "example": "https://example.com/research/source-1"
          },
          "title": {
            "type": "string",
            "description": "Title of the source document.",
            "example": "Illustrative source document"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "URL of the source document.",
            "example": "https://example.com/research/source-1"
          },
          "content": {
            "type": "string",
            "description": "Extracted text content in markdown format, truncated to `response_length`.",
            "example": "Placeholder content representing the text returned from a source."
          },
          "description": {
            "type": "string",
            "nullable": true,
            "description": "Short description or meta summary of the document.",
            "example": "Illustrative metadata, not a factual research finding."
          },
          "source": {
            "type": "string",
            "description": "Source identifier. `\"web\"` for web results, or a proprietary source name.",
            "example": "web"
          },
          "price": {
            "type": "number",
            "description": "Cost charged for this individual result.",
            "example": 0.000625
          },
          "length": {
            "type": "integer",
            "description": "Character count of the `content` field.",
            "example": 65
          },
          "image_url": {
            "nullable": true,
            "description": "Image URLs associated with this result, keyed by index. `null` if no images.",
            "oneOf": [
              {
                "type": "object",
                "additionalProperties": {
                  "type": "string",
                  "format": "uri"
                }
              },
              {
                "type": "string",
                "format": "uri"
              }
            ],
            "example": {
              "0": "https://example.com/images/source-image.png"
            }
          },
          "relevance_score": {
            "type": "number",
            "description": "Relevance score from reranking (0.0-1.0). Higher is more relevant.",
            "minimum": 0.0,
            "maximum": 1.0,
            "example": 0.92
          },
          "data_type": {
            "type": "string",
            "description": "Format of the content field.",
            "enum": [
              "unstructured",
              "structured"
            ],
            "example": "unstructured"
          },
          "source_type": {
            "type": "string",
            "description": "Classification of the source.\n\n- `website` - General web page\n- `forum` - Forum or discussion thread\n- `paper` - Academic paper\n- `data` - Structured data source\n- `report` - Report or analysis\n- `health_data` - Healthcare data\n- `clinical_trial` - Clinical trial record\n- `drug_label` - FDA drug label\n- `grants` - Research grant",
            "enum": [
              "website",
              "forum",
              "paper",
              "data",
              "report",
              "health_data",
              "clinical_trial",
              "drug_label",
              "grants"
            ],
            "example": "website"
          },
          "publication_date": {
            "type": "string",
            "description": "Publication date in `YYYY-MM-DD` format, or empty string if unknown.",
            "example": "2024-06-15"
          },
          "crawl_date": {
            "type": "string",
            "description": "When the page was crawled (web results). With `historical_cache`, it is second-precision and never later than the `end_date` cutoff.",
            "example": "2024-06-16T08:12:45Z"
          },
          "abstract": {
            "type": "string",
            "description": "Document-level abstract for academic results when available.",
            "example": "Placeholder abstract; the actual abstract depends on the returned paper."
          },
          "doi": {
            "type": "string",
            "description": "DOI identifier (academic results only)."
          },
          "citation": {
            "type": "string",
            "description": "Citation text (academic results only).",
            "example": ""
          },
          "citation_count": {
            "type": "integer",
            "description": "Number of citations (academic results only)."
          },
          "authors": {
            "type": "array",
            "description": "Author names (academic results only).",
            "items": {
              "type": "string"
            }
          },
          "references": {
            "type": "string",
            "description": "References text (academic results only).",
            "example": ""
          },
          "metadata": {
            "type": "object",
            "description": "Additional structured metadata (financial and specialized results only).",
            "additionalProperties": true
          }
        }
      },
      "SearchResponse": {
        "type": "object",
        "description": "Search response containing results and metadata.",
        "required": [
          "success",
          "tx_id",
          "query",
          "results",
          "results_by_source",
          "total_deduction_dollars",
          "total_characters"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Whether the search completed successfully.",
            "example": true
          },
          "error": {
            "type": "string",
            "nullable": true,
            "description": "Error or warning message. May be non-empty even on successful responses if some sources had issues.",
            "example": null
          },
          "tx_id": {
            "type": "string",
            "description": "Transaction ID for tracking and support.",
            "example": "tx_a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          },
          "query": {
            "type": "string",
            "description": "The original query as submitted.",
            "example": "latest developments in quantum computing"
          },
          "results": {
            "type": "array",
            "description": "Search results ordered by relevance.",
            "items": {
              "$ref": "#/components/schemas/SearchResult"
            }
          },
          "results_by_source": {
            "type": "object",
            "description": "Count of results broken down by source type.",
            "properties": {
              "web": {
                "type": "integer",
                "description": "Number of web results.",
                "example": 5
              },
              "proprietary": {
                "type": "integer",
                "description": "Number of proprietary results.",
                "example": 3
              }
            },
            "example": {
              "web": 1,
              "proprietary": 1
            }
          },
          "total_deduction_dollars": {
            "type": "number",
            "description": "Total cost charged for this search.",
            "example": 0.0009375
          },
          "total_characters": {
            "type": "integer",
            "description": "Sum of all result content lengths in characters.",
            "example": 174
          },
          "warnings": {
            "type": "array",
            "description": "What the search skipped or adjusted, for example named datasets outside your plan. Present only when there is something to say. New warning types may be added at any time. See [Warnings](https://docs.valyu.ai/api-reference/warnings).",
            "items": {
              "$ref": "#/components/schemas/Warning"
            }
          },
          "source_scope": {
            "type": "object",
            "description": "Receipt for a `scope_policy: \"strict\"` request. Present only for strict requests. It shows which datasets were dispatched and which returned rows. It does not certify full coverage: a dataset with no returned rows was not necessarily searched and found empty.",
            "properties": {
              "policy": {
                "type": "string",
                "enum": [
                  "strict"
                ],
                "description": "Scope policy applied."
              },
              "allowed_dataset_ids": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Datasets in scope after exclusions."
              },
              "selected_dataset_ids": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "In-scope datasets the search was dispatched to."
              },
              "completed_dataset_ids": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Datasets confirmed as fully searched. Currently always empty."
              },
              "returned_dataset_ids": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Datasets that contributed at least one returned result."
              },
              "omitted_dataset_ids": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "In-scope datasets that were not dispatched."
              },
              "selection_basis": {
                "type": "string",
                "description": "How `selected_dataset_ids` was determined.",
                "example": "dispatch_requested"
              },
              "coverage": {
                "type": "string",
                "description": "Coverage claim. Currently always `unknown`.",
                "example": "unknown"
              },
              "exhaustive": {
                "type": "boolean",
                "description": "Whether the search is certified exhaustive. Currently always `false`.",
                "example": false
              },
              "errors": {
                "type": "array",
                "description": "One entry per dataset that failed during the search (max 32).",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string",
                      "example": "source_execution_error"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "ContentsRequest": {
        "type": "object",
        "required": [
          "urls"
        ],
        "additionalProperties": true,
        "description": "Content extraction request parameters.",
        "properties": {
          "urls": {
            "type": "array",
            "description": "URLs to extract content from. Must be valid HTTP/HTTPS URLs. Duplicates are silently removed.",
            "items": {
              "type": "string",
              "format": "uri"
            },
            "minItems": 1,
            "maxItems": 50,
            "example": [
              "https://en.wikipedia.org/wiki/Quantum_computing",
              "https://example.com/selected-paper"
            ]
          },
          "response_length": {
            "description": "Maximum character length of extracted content per URL.\n\n- `\"short\"` - 25,000 characters (default)\n- `\"medium\"` - 50,000 characters\n- `\"large\"` - 100,000 characters\n- `\"max\"` - No limit\n- Any positive integer for a custom character limit",
            "oneOf": [
              {
                "type": "string",
                "enum": [
                  "short",
                  "medium",
                  "large",
                  "max"
                ]
              },
              {
                "type": "integer",
                "minimum": 1
              }
            ],
            "default": "short"
          },
          "max_price_dollars": {
            "type": "number",
            "description": "Maximum budget for this request. Defaults to 2x the maximum possible cost.\n\n- If the worst-case cost exceeds this value, the request is rejected before processing with 400.\n- If the actual cost after processing exceeds it, the request returns 402.",
            "minimum": 0,
            "exclusiveMinimum": true,
            "example": 0.05
          },
          "summary": {
            "description": "Controls AI-powered content processing. Brings the price to 0.6 credits per successfully extracted URL in total (0.2 base plus 0.4 for AI processing) when enabled. A text summary and structured extraction cost the same. If the AI step fails for a URL, only the 0.2 credit base is charged.\n\n- `false` - No AI processing, raw extracted content only (default)\n- `true` - Generate a text summary of each page\n- `\"string\"` - Generate a summary guided by custom instructions (max 500 characters)\n- `{json_schema}` - Extract structured data matching the provided JSON schema",
            "oneOf": [
              {
                "type": "boolean"
              },
              {
                "type": "string",
                "maxLength": 500
              },
              {
                "type": "object",
                "description": "JSON Schema for structured extraction. Supports types: object, array, string, number, integer, boolean."
              }
            ],
            "default": false
          },
          "extract_effort": {
            "type": "string",
            "description": "Controls how pages are rendered for extraction.\n\n- `\"auto\"` - Automatically selects the best method per URL (default)\n- `\"normal\"` - HTTP-only extraction, fastest\n- `\"high\"` - Full Chrome rendering, best for JavaScript-heavy pages",
            "enum": [
              "auto",
              "normal",
              "high"
            ],
            "default": "auto"
          },
          "start_date": {
            "type": "string",
            "description": "Start of the date window for point-in-time extraction. Accepts `YYYY`, `YYYY-MM-DD` or an ISO-8601 datetime. Use with `historical_cache`.",
            "example": "2024-01-01"
          },
          "end_date": {
            "type": "string",
            "description": "End of the date window (the cutoff) for point-in-time extraction. Accepts `YYYY`, `YYYY-MM-DD` or an ISO-8601 datetime. A year alone means the last day of that year. `start_date` must be on or before `end_date`.",
            "example": "2024-12-31"
          },
          "historical_cache": {
            "type": "boolean",
            "description": "Serve a snapshot captured inside the date window instead of a live crawl. On Contents this always applies `historical_cache_strict: \"only\"`: a URL with no qualifying snapshot fails rather than falling back to a live crawl.",
            "default": false
          },
          "historical_cache_strict": {
            "type": "string",
            "enum": [
              "off",
              "prefer",
              "only"
            ],
            "description": "Snapshot policy. Accepted for parity with Search, but on Contents any request with `historical_cache: true` uses `only`, whatever value is passed."
          },
          "screenshot": {
            "type": "boolean",
            "description": "Capture a screenshot of each page. The screenshot URL is returned in each result's `screenshot_url` field.",
            "default": false
          },
          "include_image_links": {
            "type": "boolean",
            "description": "Keep image URLs in the content. When `true` (default), images stay as markdown, for example `![Product photo](https://example.com/p.jpg)`. When `false`, each image becomes `[Image: Product photo]`. The API removes the image URL and keeps the alt text. The API removes an image with no alt text. A linked image `[![alt](src)](href)` becomes `[[Image: alt]](href)`. Other links do not change. Set `false` to use fewer tokens.",
            "default": true
          },
          "max_age": {
            "type": "integer",
            "minimum": 0,
            "maximum": 2592000,
            "description": "The oldest cached copy of a page, in seconds, that you accept. `0` forces a live crawl. Omit it for the default cache policy: a copy up to 7 days old, with a background refresh when it is older than 5 minutes. A value from 1 to 2592000 (30 days) accepts a copy at most that old and starts no background refresh. Cannot be used with `historical_cache`. Works with `async` too. Billing does not change.",
            "example": 3600
          },
          "async": {
            "type": "boolean",
            "description": "Process URLs asynchronously in the background. Returns a `job_id` to poll via `GET /v1/contents/jobs/{job_id}`. Required when submitting more than 10 URLs (maximum 50). Also useful for slow, JavaScript-heavy pages.",
            "default": false
          },
          "webhook_url": {
            "type": "string",
            "format": "uri",
            "description": "HTTPS URL to receive a webhook POST when async processing completes. Only used when `async` is `true`. The webhook payload is signed with HMAC-SHA256.",
            "example": "https://example.com/webhooks/valyu"
          }
        }
      },
      "ContentResult": {
        "type": "object",
        "description": "Extracted content from a single URL.",
        "required": [
          "url",
          "status"
        ],
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "description": "The URL that was processed.",
            "example": "https://example.com/research/source-1"
          },
          "status": {
            "type": "string",
            "description": "Processing status for this URL. `not_found` means that the page is a not-found page (a 404 with no real content). Only `success` results are charged.",
            "enum": [
              "success",
              "failed",
              "not_found"
            ],
            "example": "success"
          },
          "title": {
            "type": "string",
            "description": "Page title. Present when `status` is `\"success\"`.",
            "example": "Illustrative source document"
          },
          "content": {
            "description": "Extracted content. Markdown string when `data_type` is `\"unstructured\"`, JSON object when `data_type` is `\"structured\"`. Present when `status` is `\"success\"`.",
            "oneOf": [
              {
                "type": "string",
                "description": "Markdown-formatted content."
              },
              {
                "type": "object",
                "description": "Structured data matching the provided JSON schema."
              }
            ],
            "example": "Placeholder content representing the text returned from a source."
          },
          "description": {
            "type": "string",
            "description": "Meta description of the page.",
            "example": "Illustrative metadata, not a factual research finding."
          },
          "source": {
            "type": "string",
            "description": "`\"web\"` for web pages, or the dataset id for academic papers served from Valyu's processed index (e.g. `valyu/valyu-arxiv`, `valyu/valyu-pubmed`, `valyu/valyu-biorxiv`, `valyu/valyu-medrxiv`, `valyu/valyu-chemrxiv`).",
            "example": "web"
          },
          "price": {
            "type": "number",
            "description": "Base extraction price for this URL (0.2 credits). Excludes AI processing for `summary` (0.4 credits more, 0.6 credits in total); use the response's `total_cost_dollars` for the amount charged.",
            "example": 0.00125
          },
          "length": {
            "type": "integer",
            "description": "Character count of the `content` field.",
            "example": 65
          },
          "data_type": {
            "type": "string",
            "description": "`\"unstructured\"` for text content, `\"structured\"` when JSON schema extraction succeeded.",
            "enum": [
              "unstructured",
              "structured"
            ],
            "example": "unstructured"
          },
          "source_type": {
            "type": "string",
            "description": "Classification of the content type. `\"paper\"` for academic papers served from the processed index.",
            "enum": [
              "website",
              "pdf",
              "txt",
              "json",
              "xml",
              "sitemap",
              "csv",
              "paper"
            ],
            "example": "website"
          },
          "publication_date": {
            "type": "string",
            "description": "Publication date in `YYYY-MM-DD` format, or empty string if unknown.",
            "example": "2024-03-15"
          },
          "cache_state": {
            "type": "string",
            "enum": ["hit", "miss", "stale"],
            "description": "How the page was served. `miss`: this request crawled the page. `hit`: a cached copy answered the request and was fresh for you. `stale`: the page cache served a copy older than 5 minutes for a request with no `max_age`, and the page is refreshed in the background. Papers served from the processed index return `hit`. Present when `status` is `\"success\"`.",
            "example": "miss"
          },
          "crawled_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Time that the page copy was captured, in ISO 8601. For `miss` it is the crawl time. `null` when there is no page copy to date, for example a paper served from the processed index. Present when `status` is `\"success\"`.",
            "example": "2026-10-28T10:15:00+00:00"
          },
          "final_url": {
            "type": "string",
            "format": "uri",
            "description": "The page that Contents read, when the URL redirected to a different page. For example, a closed job posting can redirect to the careers page. Not present when there was no redirect. A change of scheme, host case, `www.`, trailing slash or fragment is not a different page.",
            "example": "https://example.com/careers"
          },
          "http_status": {
            "type": "integer",
            "enum": [404],
            "description": "Present, and always `404`, only when the server answered 404 but the body is the real page. Such a result has `status` `\"success\"` and is charged like any other success. A not-found template page has `status` `\"not_found\"` and no `http_status`.",
            "example": 404
          },
          "id": {
            "type": "string",
            "description": "Identifier for this result. The URL for web pages, or the bare paper id / DOI for academic papers (e.g. `2506.05440`, `10.26434/chemrxiv-2025-chn4j`).",
            "example": "https://example.com/research/source-1"
          },
          "image_url": {
            "type": "object",
            "description": "Image URLs found on the page, keyed by index.",
            "additionalProperties": {
              "type": "string",
              "format": "uri"
            },
            "example": {
              "0": "https://example.com/images/source-image.png"
            }
          },
          "screenshot_url": {
            "type": "string",
            "format": "uri",
            "description": "Screenshot URL. Present only when `screenshot` was enabled; omitted otherwise.",
            "example": "https://example.com/screenshots/source-1.png"
          },
          "summary": {
            "description": "AI-generated summary or structured extraction result. Only present when `summary` was enabled in the request.",
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "additionalProperties": true
              }
            ]
          },
          "summary_success": {
            "type": "boolean",
            "description": "Whether AI processing succeeded. Only present when `summary` was enabled."
          },
          "structured_metadata": {
            "type": "object",
            "description": "Metadata from structured data extraction. Only present when `data_type` is `\"structured\"`.",
            "additionalProperties": true
          },
          "error": {
            "type": "string",
            "description": "Human-readable failure reason. Only present when `status` is `\"failed\"` or `\"not_found\"`. For `not_found` it is `Page not found (404)`. Describes why extraction failed without exposing internal infrastructure.",
            "example": "Could not extract content from this URL. The page may be unavailable, require sign-in, or block automated access."
          },
          "doi": {
            "type": "string",
            "description": "Paper DOI. Present for academic papers served from the processed index."
          },
          "authors": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Paper authors. Present for academic papers served from the processed index."
          },
          "citation_count": {
            "type": "integer",
            "description": "Citation count. Present for academic papers served from the processed index."
          }
        }
      },
      "ContentsResponse": {
        "type": "object",
        "description": "Synchronous content extraction response.",
        "required": [
          "success",
          "tx_id",
          "urls_requested",
          "urls_processed",
          "urls_failed",
          "results",
          "total_cost_dollars",
          "total_characters"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Whether the extraction completed successfully.",
            "example": true
          },
          "error": {
            "type": "string",
            "nullable": true,
            "description": "Error message if some URLs failed. `null` on complete success.",
            "example": null
          },
          "tx_id": {
            "type": "string",
            "description": "Transaction ID for tracking.",
            "example": "tx_a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          },
          "urls_requested": {
            "type": "integer",
            "description": "Number of deduplicated URLs submitted.",
            "example": 3
          },
          "urls_processed": {
            "type": "integer",
            "description": "Number of URLs successfully processed.",
            "example": 3
          },
          "urls_failed": {
            "type": "integer",
            "description": "Number of URLs that failed processing.",
            "example": 0
          },
          "results": {
            "type": "array",
            "description": "Extraction results for each URL.",
            "items": {
              "$ref": "#/components/schemas/ContentResult"
            }
          },
          "total_cost_dollars": {
            "type": "number",
            "description": "Total amount charged, including AI processing (0.4 credits on top of the 0.2 credit base, 0.6 credits in total per URL). Only successfully extracted URLs are charged.",
            "example": 0.00375
          },
          "total_characters": {
            "type": "integer",
            "description": "Sum of all result content lengths.",
            "example": 45230
          }
        }
      },
      "ContentsAsyncResponse": {
        "type": "object",
        "description": "Response returned when async processing is initiated.",
        "required": [
          "success",
          "job_id",
          "status",
          "urls_total",
          "poll_url",
          "tx_id"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Whether the async job was created successfully.",
            "example": true
          },
          "job_id": {
            "type": "string",
            "description": "Job identifier for polling status.",
            "example": "cj_a1b2c3d4e5f6g7h8"
          },
          "status": {
            "type": "string",
            "description": "Initial job status.",
            "enum": [
              "pending"
            ],
            "example": "pending"
          },
          "urls_total": {
            "type": "integer",
            "description": "Total number of URLs queued for processing.",
            "example": 25
          },
          "poll_url": {
            "type": "string",
            "description": "Relative URL to poll for job status.",
            "example": "/contents/jobs/cj_a1b2c3d4e5f6g7h8"
          },
          "tx_id": {
            "type": "string",
            "description": "Transaction ID.",
            "example": "tx_a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          },
          "webhook_secret": {
            "type": "string",
            "description": "HMAC-SHA256 secret for verifying webhook payloads. Only present when `webhook_url` was provided.",
            "example": "EXAMPLE_WEBHOOK_SECRET_REPLACE_WITH_RETURNED_VALUE"
          }
        }
      },
      "ContentsJobResponse": {
        "type": "object",
        "description": "Async job status and results.",
        "required": [
          "success",
          "job_id",
          "status",
          "urls_total",
          "urls_processed",
          "urls_failed"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Whether the request succeeded.",
            "example": true
          },
          "job_id": {
            "type": "string",
            "description": "Unique identifier for the async job.",
            "example": "cj_a1b2c3d4e5f6g7h8"
          },
          "status": {
            "type": "string",
            "description": "Current job status.\n\n- `pending` - Job created, not yet started\n- `processing` - URLs are being processed\n- `completed` - All URLs processed successfully\n- `partial` - Processing finished with some failures\n- `failed` - All URLs failed. The response still lists every URL in `results`, each with its `status` and `error`.",
            "enum": [
              "pending",
              "processing",
              "completed",
              "partial",
              "failed"
            ],
            "example": "completed"
          },
          "urls_total": {
            "type": "integer",
            "description": "Total number of URLs to process.",
            "example": 25
          },
          "urls_processed": {
            "type": "integer",
            "description": "Number of URLs successfully processed so far.",
            "example": 23
          },
          "urls_failed": {
            "type": "integer",
            "description": "Number of URLs that failed processing.",
            "example": 2
          },
          "created_at": {
            "type": "integer",
            "description": "Job creation time as Unix timestamp in milliseconds.",
            "example": 1707000000000
          },
          "updated_at": {
            "type": "integer",
            "description": "Last update time as Unix timestamp in milliseconds.",
            "example": 1707000060000
          },
          "current_batch": {
            "type": "integer",
            "description": "Current batch being processed. Only present when `status` is `\"processing\"`.",
            "example": 3
          },
          "total_batches": {
            "type": "integer",
            "description": "Total number of batches. Only present when `status` is `\"processing\"`.",
            "example": 5
          },
          "results": {
            "type": "array",
            "description": "One result for each URL, each with its own `status` and, if the URL did not succeed, an `error`. Present when `status` is `\"completed\"`, `\"partial\"` or `\"failed\"`. A not-found page (a 404 with no real content) is a row with `status` `\"not_found\"`, not a missing row.",
            "items": {
              "$ref": "#/components/schemas/ContentResult"
            }
          },
          "actual_cost_dollars": {
            "type": "number",
            "description": "Total cost. Present when the job is finished (`completed`, `partial` or `failed`). It is 0 when no URL succeeded.",
            "example": 0.02875
          },
          "error": {
            "type": "string",
            "description": "Job-level error message. Can be absent on a `failed` or `partial` job when every failure is per-URL. Read the `error` of each result for the reason."
          }
        }
      },
      "AnswerRequest": {
        "type": "object",
        "required": [
          "query"
        ],
        "additionalProperties": false,
        "description": "Answer API request parameters.",
        "properties": {
          "query": {
            "type": "string",
            "description": "The question or research query to answer.",
            "example": "What are the latest FDA-approved treatments for type 2 diabetes?"
          },
          "search_type": {
            "type": "string",
            "description": "Controls which data sources are searched.\n\n- `all` - Web and proprietary sources (default)\n- `web` - Web search only\n- `proprietary` - Academic, financial, and premium sources only\n- `news` - News articles only",
            "enum": [
              "all",
              "web",
              "proprietary",
              "news"
            ],
            "default": "all"
          },
          "included_sources": {
            "type": "array",
            "description": "Sources to include. Accepts domains, URLs, dataset identifiers, or presets (`\"finance\"`, `\"medical\"`).",
            "items": {
              "type": "string"
            },
            "example": [
              "pubmed.ncbi.nlm.nih.gov"
            ]
          },
          "excluded_sources": {
            "type": "array",
            "description": "Sources to exclude. Accepts domains, URLs and dataset identifiers. Presets are not supported.",
            "items": {
              "type": "string"
            }
          },
          "data_max_price": {
            "type": "number",
            "description": "Maximum budget for the search component of the answer. It does not cap content extraction or AI processing.",
            "default": 1.0,
            "minimum": 0,
            "exclusiveMinimum": true,
            "example": 1.0
          },
          "start_date": {
            "type": "string",
            "format": "date",
            "description": "Filter results published on or after this date. Format: `YYYY-MM-DD`.",
            "example": "2024-01-01"
          },
          "end_date": {
            "type": "string",
            "format": "date",
            "description": "Filter results published on or before this date. Format: `YYYY-MM-DD`.",
            "example": "2024-12-31"
          },
          "country_code": {
            "type": "string",
            "description": "ISO 3166-1 alpha-2 country code for geo-targeted search.",
            "enum": [
              "ALL",
              "AR",
              "AU",
              "AT",
              "BE",
              "BR",
              "CA",
              "CL",
              "DK",
              "FI",
              "FR",
              "DE",
              "HK",
              "IN",
              "ID",
              "IT",
              "JP",
              "KR",
              "MY",
              "MX",
              "NL",
              "NZ",
              "NO",
              "CN",
              "PL",
              "PT",
              "PH",
              "RU",
              "SA",
              "ZA",
              "ES",
              "SE",
              "CH",
              "TW",
              "TR",
              "GB",
              "US"
            ]
          },
          "fast_mode": {
            "type": "boolean",
            "description": "Enable fast mode for lower latency. Uses 3 tool call rounds instead of 2 and higher result counts per query.",
            "default": false
          },
          "structured_output": {
            "type": "object",
            "nullable": true,
            "description": "JSON Schema defining the desired output structure. When set, the AI returns a JSON object matching this schema instead of free-form text. Max depth 10, max 50 properties, max 5000 characters.",
            "example": {
              "type": "object",
              "properties": {
                "treatments": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "approval_date": {
                        "type": "string"
                      },
                      "mechanism": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "system_instructions": {
            "type": "string",
            "nullable": true,
            "description": "Custom system instructions for the AI. Replaces the default research agent prompt. Max 2000 characters.",
            "maxLength": 2000,
            "example": "You are a medical research assistant. Cite all sources."
          }
        }
      },
      "SearchConfig": {
        "type": "object",
        "description": "Search configuration for DeepResearch tasks.",
        "properties": {
          "search_type": {
            "type": "string",
            "enum": [
              "all",
              "web",
              "proprietary"
            ],
            "description": "Controls which data sources are searched.",
            "default": "all"
          },
          "included_sources": {
            "type": "array",
            "description": "Sources to include. Max 20 items.",
            "items": {
              "type": "string"
            },
            "maxItems": 20
          },
          "excluded_sources": {
            "type": "array",
            "description": "Sources to exclude. Max 20 items.",
            "items": {
              "type": "string"
            },
            "maxItems": 20
          },
          "source_biases": {
            "type": "object",
            "description": "Bias values for specific sources to influence ranking (-5 to +5). Applied to every search call during research.",
            "additionalProperties": {
              "type": "integer",
              "minimum": -5,
              "maximum": 5
            }
          },
          "country_code": {
            "type": "string",
            "enum": [
              "ALL",
              "AR",
              "AU",
              "AT",
              "BE",
              "BR",
              "CA",
              "CL",
              "DK",
              "FI",
              "FR",
              "DE",
              "HK",
              "IN",
              "ID",
              "IT",
              "JP",
              "KR",
              "MY",
              "MX",
              "NL",
              "NZ",
              "NO",
              "CN",
              "PL",
              "PT",
              "PH",
              "RU",
              "SA",
              "ZA",
              "ES",
              "SE",
              "CH",
              "TW",
              "TR",
              "GB",
              "US"
            ],
            "description": "Country code for geo-targeted search."
          },
          "start_date": {
            "type": "string",
            "format": "date",
            "description": "Filter results from this date. Format: `YYYY-MM-DD`."
          },
          "end_date": {
            "type": "string",
            "format": "date",
            "description": "Filter results until this date. Format: `YYYY-MM-DD`. Must be >= `start_date`."
          },
          "historical_cache": {
            "type": "boolean",
            "description": "With `end_date`, pins the run to that date for backtests: research is limited to sources published by that date, and searches prefer snapshots captured on or before it. Dates before 2026 return a 400."
          },
          "historical_cache_strict": {
            "type": "string",
            "enum": ["off", "prefer", "only"],
            "description": "Snapshot policy for a backtest run (`reference_date`, or `end_date` with `historical_cache: true`). Applies to every web search, page read, screenshot and URL in the task. `prefer` uses a snapshot captured at or before the cutoff when one exists, and otherwise reads the live page, so a page can contain text written after the cutoff. `only` never reads a live page: a page with no snapshot at or before the cutoff is dropped. `off` allows live pages without snapshot checks; the cutoff still bounds publication dates. For strict backtests, use `only`. Has no effect when the run has no cutoff.",
            "default": "prefer"
          },
          "reference_date": {
            "type": "string",
            "description": "Pins the run to this date for backtests, as `historical_cache` does with `end_date`. Takes precedence over `end_date`. Format: `YYYY-MM-DD` or an ISO-8601 datetime. Dates before 2026 return a 400.",
            "example": "2026-07-31"
          }
        }
      },
      "FileAttachment": {
        "type": "object",
        "description": "A file to include in the research task.",
        "required": [
          "data",
          "filename",
          "mediaType"
        ],
        "properties": {
          "data": {
            "type": "string",
            "description": "File content as a data URL. Format: `data:<mediaType>;base64,<base64data>`.",
            "example": "data:application/pdf;base64,JVBERi0xLjQK..."
          },
          "filename": {
            "type": "string",
            "description": "Original filename.",
            "example": "research_paper.pdf"
          },
          "mediaType": {
            "type": "string",
            "description": "MIME type of the file.",
            "example": "application/pdf"
          },
          "context": {
            "type": "string",
            "description": "Optional context about the file to guide the research agent. Maximum 50,000 characters per file and 100,000 characters combined across all files.",
            "maxLength": 50000
          }
        }
      },
      "MCPServerConfig": {
        "type": "object",
        "description": "MCP (Model Context Protocol) server configuration for tool access during research.",
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "description": "HTTP/HTTPS URL of the MCP server.",
            "example": "https://mcp.example.com/tools"
          },
          "name": {
            "type": "string",
            "description": "Display name for the MCP server."
          },
          "tool_prefix": {
            "type": "string",
            "description": "Prefix for tool names. Defaults to the server hostname."
          },
          "auth": {
            "type": "object",
            "description": "Authentication configuration.",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "bearer",
                  "header",
                  "none"
                ],
                "description": "Authentication type."
              },
              "token": {
                "type": "string",
                "description": "Bearer token (when `type` is `\"bearer\"`)."
              },
              "headers": {
                "type": "object",
                "description": "Custom headers (when `type` is `\"header\"`).",
                "additionalProperties": {
                  "type": "string"
                }
              }
            }
          },
          "allowed_tools": {
            "type": "array",
            "description": "Whitelist of tool names to expose. If omitted, all tools are available.",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "DeepResearchCreateRequest": {
        "type": "object",
        "anyOf": [
          { "required": ["query"] },
          { "required": ["input"] },
          { "required": ["workflow_id"] }
        ],
        "additionalProperties": false,
        "description": "Request to create a DeepResearch task.\n\nA task can be either **freeform** (provide `query`/`input` plus optional `research_strategy`, `report_format`, etc.) or **workflow-driven** (provide `workflow_id` + `workflow_params`). The two modes are mutually exclusive: passing `workflow_id` alongside freeform fields (`query`, `input`, `research_strategy`, `report_format`) returns `400 workflow_and_freeform_mutually_exclusive`. When running a workflow, any `mode`/`deliverables`/`tools` you pass in the body override the template defaults.",
        "properties": {
          "query": {
            "type": "string",
            "description": "The research query or question. Use `query` (preferred) or `input` (deprecated). Maximum 25,000 characters. Mutually exclusive with `workflow_id`.",
            "maxLength": 25000,
            "example": "Comprehensive analysis of CRISPR gene therapy clinical trials in 2024"
          },
          "input": {
            "type": "string",
            "deprecated": true,
            "description": "**Deprecated.** Use `query` instead."
          },
          "workflow_id": {
            "type": "string",
            "description": "**Beta.** Slug of a workflow to run instead of a freeform query. When set, the task is resolved from the workflow's prompt template using `workflow_params`. Mutually exclusive with freeform fields (`query`, `input`, `research_strategy`, `report_format`); supplying both returns `400 workflow_and_freeform_mutually_exclusive`. See the [Workflows](#tag/Workflows) endpoints.",
            "example": "ib-company-profile"
          },
          "workflow_params": {
            "type": "object",
            "description": "**Beta.** Values for the workflow's template variables, keyed by variable `key`. Required when `workflow_id` is set. Values must satisfy the workflow's declared variable types and validation rules.",
            "additionalProperties": {
              "oneOf": [
                { "type": "string" },
                { "type": "number" },
                { "type": "boolean" }
              ]
            },
            "example": {
              "company": "NVIDIA (NVDA)"
            }
          },
          "workflow_version": {
            "type": "integer",
            "description": "**Beta.** Pin the run to a specific immutable version of the workflow. Defaults to the workflow's current version when omitted. Only valid with `workflow_id`.",
            "minimum": 1,
            "example": 1
          },
          "mode": {
            "type": "string",
            "description": "Research mode controlling depth and cost. Prices are credits per task; tool add-ons are extra. See [pricing](https://docs.valyu.ai/pricing).\n\n| Mode | Credits | Best For | Max Steps |\n| --- | --- | --- | --- |\n| `instant` | 8 | Short, cited answers in under 30 seconds | 1 |\n| `fast` | 25 | Quick queries, batch processing | 12 |\n| `standard` | 100 | Balanced research | 25 |\n| `heavy` | 500 | Complex topics requiring deep analysis | 45 |\n| `max` | 2,500 | Larger research budget for complex tasks | 75 |",
            "enum": [
              "instant",
              "fast",
              "standard",
              "heavy",
              "max"
            ],
            "default": "standard",
            "example": "standard"
          },
          "model": {
            "type": "string",
            "deprecated": true,
            "description": "**Deprecated.** Use `mode` instead.",
            "enum": [
              "fast",
              "standard",
              "heavy",
              "max"
            ]
          },
          "strategy": {
            "type": "string",
            "deprecated": true,
            "description": "**Deprecated.** Use `research_strategy` instead. Natural language strategy to guide the research agent's approach.",
            "example": "Focus on Phase 3 trials and compare efficacy data across studies"
          },
          "research_strategy": {
            "type": "string",
            "description": "Natural language strategy to guide the research phase. Controls how the agent searches, what sources to prioritize, and research methodology. Combined length of `research_strategy` and `report_format` must not exceed 15,000 characters.",
            "maxLength": 15000,
            "example": "Focus on Phase 3 trials and compare efficacy data across studies"
          },
          "report_format": {
            "type": "string",
            "description": "Natural language instructions for the output format. Has highest priority and overrides default formatting. Controls structure, style, length, and presentation of the final report. Combined length of `research_strategy` and `report_format` must not exceed 15,000 characters.",
            "maxLength": 15000,
            "example": "Write a 2-page executive summary with bullet points and a comparison table"
          },
          "search": {
            "$ref": "#/components/schemas/SearchConfig"
          },
          "urls": {
            "type": "array",
            "description": "URLs to include in the research context. Max 50. The first 10 are free. Each extra URL costs 8 credits. Scanned pages (OCR) in URL files cost 2.4 credits per page, for tasks created from 2026-11-13.",
            "items": {
              "type": "string",
              "format": "uri"
            },
            "maxItems": 50,
            "example": [
              "https://example.com/selected-trial-record"
            ]
          },
          "files": {
            "type": "array",
            "description": "Files to analyze as part of the research. Max 10. Scanned pages (OCR) cost 2.4 credits per page, for tasks created from 2026-11-13.",
            "items": {
              "$ref": "#/components/schemas/FileAttachment"
            },
            "maxItems": 10
          },
          "output_formats": {
            "type": "array",
            "description": "Desired output formats. Defaults to `[\"markdown\"]`.\n\n- `\"markdown\"` - Markdown report (default)\n- `\"pdf\"` - PDF document (can combine with `\"markdown\"`)\n- `\"toon\"` - Token-efficient structured output; requires a JSON Schema object to also be supplied\n- JSON Schema object - Structured JSON output\n\nA JSON Schema object cannot be combined with `\"markdown\"` or `\"pdf\"`. `\"toon\"` requires a JSON Schema object.",
            "items": {
              "oneOf": [
                {
                  "type": "string",
                  "enum": [
                    "markdown",
                    "pdf",
                    "toon"
                  ]
                },
                {
                  "type": "object",
                  "description": "JSON Schema for structured output."
                }
              ]
            },
            "default": [
              "markdown"
            ],
            "example": [
              "markdown",
              "pdf"
            ]
          },
          "metadata": {
            "type": "object",
            "description": "Arbitrary key-value metadata to attach to the task.",
            "additionalProperties": {
              "oneOf": [
                {
                  "type": "string"
                },
                {
                  "type": "number"
                },
                {
                  "type": "boolean"
                }
              ]
            },
            "example": {
              "project": "drug-discovery",
              "priority": "high"
            }
          },
          "mcp_servers": {
            "type": "array",
            "description": "MCP servers to provide additional tools during research. Max 5.",
            "items": {
              "$ref": "#/components/schemas/MCPServerConfig"
            },
            "maxItems": 5
          },
          "code_execution": {
            "type": "boolean",
            "description": "Deprecated: use tools.code_execution instead. Enable code execution capability.",
            "default": false,
            "deprecated": true
          },
          "tools": {
            "type": "object",
            "description": "Controls which optional tools the research agent can use. Each tool accepts an object with `enabled` (boolean, default true) and optional `max_calls` (integer, capped at system default).",
            "properties": {
              "x_search": {
                "type": "boolean",
                "description": "X search runs automatically for organisations with X access. It costs 32 credits for each call that returns posts. Send `false` to turn it off.",
                "default": true
              },
              "code_execution": {
                "oneOf": [
                  { "type": "boolean" },
                  {
                    "type": "object",
                    "properties": {
                      "enabled": { "type": "boolean", "default": true, "description": "Enable or disable the tool." },
                      "max_calls": { "type": "integer", "description": "Max invocations per task. Capped at system default (10)." }
                    }
                  }
                ],
                "description": "Enable code execution in a sandboxed Python environment. System default max_calls: 10."
              },
              "screenshots": {
                "oneOf": [
                  { "type": "boolean" },
                  {
                    "type": "object",
                    "properties": {
                      "enabled": { "type": "boolean", "default": true, "description": "Enable or disable the tool." },
                      "max_calls": { "type": "integer", "description": "Max invocations per task. Capped at system default (15)." }
                    }
                  }
                ],
                "description": "Enable visual screenshot capture of web pages. System default max_calls: 15."
              },
              "browser_use": {
                "oneOf": [
                  { "type": "boolean" },
                  {
                    "type": "object",
                    "properties": {
                      "enabled": { "type": "boolean", "default": true, "description": "Enable or disable the tool." },
                      "max_calls": { "type": "integer", "description": "Max invocations per task. Capped at system default (5)." }
                    }
                  }
                ],
                "description": "Enable autonomous browser sessions. System default max_calls: 5."
              },
              "charts": {
                "oneOf": [
                  { "type": "boolean" },
                  {
                    "type": "object",
                    "properties": {
                      "enabled": { "type": "boolean", "default": true, "description": "Enable or disable the tool." },
                      "max_calls": { "type": "integer", "description": "Max invocations per task. Charts default is unlimited; this field is accepted for consistency." }
                    }
                  }
                ],
                "description": "Enable chart and graph generation embedded in the final report. Free, no per-call surcharge. Unlimited per task."
              }
            }
          },
          "previous_reports": {
            "type": "array",
            "description": "DeepResearch task IDs to use as context for this task. Max 3.",
            "items": {
              "type": "string"
            },
            "maxItems": 3,
            "example": [
              "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
            ]
          },
          "webhook_url": {
            "type": "string",
            "format": "uri",
            "description": "HTTPS URL to receive a webhook POST when the task completes. Signed with HMAC-SHA256.",
            "example": "https://example.com/webhooks/deepresearch"
          },
          "alert_email": {
            "oneOf": [
              {
                "type": "string",
                "format": "email",
                "description": "Email address to notify on completion."
              },
              {
                "type": "object",
                "required": ["email"],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email",
                    "description": "Email address to notify on completion. Must belong to your organization."
                  },
                  "custom_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Custom URL template for the report link in the email. Must contain {id} which gets replaced with the deepresearch task ID.",
                    "example": "https://example.com/reports/{id}"
                  }
                }
              }
            ],
            "description": "Email notification on completion. Pass a string (email address) or an object with email and optional custom_url. The custom_url must contain {id} which gets replaced with the task ID. Email must belong to your organization."
          },
          "brand_collection_id": {
            "type": "string",
            "description": "Brand kit to apply to the PDF report and the deliverables. Send a kit ID from the Valyu platform, or `\"none\"` for no branding. If you don't send it, the organisation's default kit applies to the report and any deliverables, if the default kit is ready. Brand kits need the Comfortably Pro, Serious Business or Enterprise plan. See [Brand kits](/guides/deepresearch-brand-kits).",
            "example": "YOUR_KIT_ID"
          },
          "cover_art": {
            "type": "object",
            "description": "Cover art for this one report. It replaces the brand kit's cover art on the PDF report cover, the PDF deliverable and the title slide of a PPTX deck, and works without a kit. Send exactly one of `data` or `url`. The picture must be a PNG or JPEG, at most 2 MB after base64 decoding, and at least 800 px on the short side. Cropping it to the A4 page must keep at least 25% of it. For a large picture, send `url`. A malformed field returns `400`. A picture that cannot be used, including a private or unreachable `url`, never fails the task: the kit's cover art or the standard cover applies, and `warnings` carries `cover_art_not_used`. See [Brand kits](/guides/deepresearch-brand-kits).",
            "properties": {
              "kind": {
                "type": "string",
                "enum": ["image", "pattern"],
                "default": "image",
                "description": "`image` for a photo or illustration. `pattern` for a brand graphic, which is veiled more so it stays quiet."
              },
              "data": {
                "type": "string",
                "maxLength": 6000000,
                "description": "The picture as a data URL (`data:image/png;base64,...`) or plain base64."
              },
              "url": {
                "type": "string",
                "maxLength": 2048,
                "description": "A public https URL of the picture. DeepResearch fetches it when it renders the report."
              },
              "filename": {
                "type": "string",
                "maxLength": 255,
                "description": "The file name. Optional."
              },
              "mediaType": {
                "type": "string",
                "maxLength": 100,
                "description": "`image/png` or `image/jpeg`. Optional. Checked against the file."
              }
            }
          },
          "deliverables": {
            "type": "array",
            "description": "Deliverable files to generate from the research (e.g. Excel reports, presentations). Max 10.",
            "items": {
              "description": "A deliverable to generate from the research. Can be a string (natural language description, max 500 chars) or a structured object.",
              "oneOf": [
                {
                  "type": "string",
                  "maxLength": 500,
                  "description": "Natural language description of the deliverable."
                },
                {
                  "type": "object",
                  "required": [
                    "type",
                    "description"
                  ],
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "csv",
                        "xlsx",
                        "pptx",
                        "docx",
                        "pdf",
                        "json",
                        "html"
                      ],
                      "description": "File format for the deliverable. `json` is a structured data file, optionally checked against your `schema`. `html` is a self-contained interactive web page of the report."
                    },
                    "description": {
                      "type": "string",
                      "maxLength": 500,
                      "description": "Description of what the deliverable should contain."
                    },
                    "columns": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Suggested column names for tabular deliverables (csv, xlsx)."
                    },
                    "schema": {
                      "type": "object",
                      "description": "JSON Schema that the `json` deliverable must validate against. Optional. Without it, the file has the default shape (`title`, `as_of`, `summary`, `key_findings`, `tables`, `sources`). JSON Schema 2020-12 is the default. Draft-07 is used when the `$schema` header says so, or when the schema uses the draft-07 tuple form `items: [...]`. `$defs`, `definitions` and recursive references work. Only internal `$ref` values (`#/...`) are allowed. Patterns in `pattern` and `patternProperties` use RE2 syntax, so lookahead, lookbehind and backreferences are refused. The maximum size is 20,000 characters. Formats such as `email`, `date`, `date-time` and `uri` are checked. OpenAPI `nullable: true` is accepted. An invalid schema returns `400` with the code `DELIVERABLE_SCHEMA_INVALID`. On any other type, `schema` is ignored and the task gets a `deliverable_adjusted` warning. This field is separate from `output_formats`, which shapes the report itself."
                    }
                  }
                }
              ]
            },
            "maxItems": 10
          },
          "hitl": {
            "type": "object",
            "description": "Human-in-the-loop configuration. Enable checkpoints that pause execution at key decision points. Not available for batch requests.",
            "properties": {
              "planning_questions": {
                "type": "boolean",
                "description": "Pause before research to ask clarifying questions.",
                "default": false
              },
              "plan_review": {
                "type": "boolean",
                "description": "Pause after planning for user to review the research plan.",
                "default": false
              },
              "source_review": {
                "type": "boolean",
                "description": "Pause after research for user to filter sources by domain.",
                "default": false
              },
              "outline_review": {
                "type": "boolean",
                "description": "Pause after source review for user to review the report outline.",
                "default": false
              }
            }
          },
          "share_with": {
            "type": "array",
            "description": "People or company domains who can open the report. Each entry is an email address (`name@company.com`) or a whole company domain (`@company.com`). The report stays private: only these people and members of your organization can open it. Viewers open the share link and sign in to Valyu with that email address, which must be verified. A domain covers anyone with a verified email at exactly that domain, not its subdomains. Public email providers such as gmail.com and outlook.com can't be shared as a domain; add those people individually. An invalid entry returns `400` and no task is created. Max 100. See [Share a report](https://docs.valyu.ai/guides/deepresearch-sharing).",
            "items": {
              "type": "string"
            },
            "maxItems": 100,
            "example": [
              "anna@client.com",
              "@acme.com"
            ]
          },
          "share_notify": {
            "type": "boolean",
            "description": "Email each person in `share_with` a link to the report. Domains are never emailed.",
            "default": true
          }
        }
      },
      "DeepResearchCreateResponse": {
        "type": "object",
        "description": "Response after creating a DeepResearch task.",
        "required": [
          "deepresearch_id",
          "status",
          "mode",
          "created_at"
        ],
        "properties": {
          "deepresearch_id": {
            "type": "string",
            "description": "Unique identifier for the research task.",
            "example": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          },
          "status": {
            "type": "string",
            "description": "Initial task status. `\"running\"` if started immediately, `\"queued\"` if waiting for capacity.",
            "enum": [
              "running",
              "queued"
            ],
            "example": "running"
          },
          "mode": {
            "type": "string",
            "description": "Research mode used for this task.",
            "enum": [
              "fast",
              "standard",
              "heavy",
              "max"
            ],
            "example": "standard"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 timestamp of task creation.",
            "example": "2024-06-15T10:30:00.000Z"
          },
          "metadata": {
            "type": "object",
            "description": "Metadata attached to the task.",
            "additionalProperties": true
          },
          "public": {
            "type": "boolean",
            "description": "Whether the task is publicly accessible.",
            "example": false
          },
          "webhook_secret": {
            "type": "string",
            "description": "HMAC-SHA256 secret for verifying webhook payloads. Only present when `webhook_url` was provided."
          },
          "message": {
            "type": "string",
            "description": "Status message. Present when task is queued."
          },
          "warnings": {
            "type": "array",
            "description": "Problems with the request, for example named datasets outside your plan, a tool the mode doesn't have, a `cover_art` that cannot be used, or `share_with_not_applied` when sharing could not be applied after the task was created. The task still runs. Each entry is an object with `type`, `message` and an optional `detail`, not a string. New warning types may be added at any time. See [Warnings](https://docs.valyu.ai/api-reference/warnings).",
            "items": {
              "$ref": "#/components/schemas/Warning"
            }
          },
          "sharing": {
            "$ref": "#/components/schemas/DeepResearchSharing"
          }
        }
      },
      "DeepResearchSource": {
        "type": "object",
        "description": "A source used during research.",
        "properties": {
          "title": {
            "type": "string",
            "description": "Title of the source document.",
            "example": "Illustrative evidence source"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "URL of the source.",
            "example": "https://example.com/research/source-1"
          },
          "snippet": {
            "type": "string",
            "description": "Relevant text excerpt from the source."
          },
          "description": {
            "type": "string",
            "description": "Brief description or snippet from the source."
          },
          "source": {
            "type": "string",
            "description": "Source identifier."
          },
          "price": {
            "type": "number",
            "description": "Cost of accessing this source."
          },
          "doi": {
            "type": "string",
            "description": "DOI identifier (academic sources)."
          },
          "word_count": {
            "type": "integer",
            "description": "Word count of the source document."
          },
          "fragment": {
            "type": "string",
            "description": "Optional URL fragment that, when appended to `url`, produces a deep-link to the cited passage on the source page. For HTML sources this is a Scroll-to-Text-Fragment directive (`#:~:text=...`); for PDF sources it uses PDF Open Parameters (`#page=N&search=...`). Build deep-links by concatenating `url + fragment`. Omitted when no reliable highlight target is available - clients should fall back to the canonical `url` in that case.",
            "example": "#:~:text=Placeholder%20source%20passage"
          },
          "locations": {
            "type": "array",
            "description": "Passages from this source that support the citation. Present only when the source has them; computed results over Valyu data have none. Read it from the raw response: the released SDKs do not expose it yet.",
            "items": {
              "type": "object",
              "required": [
                "excerpt"
              ],
              "properties": {
                "excerpt": {
                  "type": "string",
                  "description": "The exact passage from the source.",
                  "example": "The design draught is 16.4 metres at lowest astronomical tide."
                },
                "page": {
                  "type": "integer",
                  "description": "Page number in the source document, when known.",
                  "example": 940
                },
                "piece": {
                  "type": "integer",
                  "description": "Which part of a long document the passage comes from, when the document was read in parts.",
                  "example": 3
                }
              }
            }
          }
        }
      },
      "DeepResearchImage": {
        "type": "object",
        "description": "An image generated during research (chart, AI-generated, or screenshot).",
        "required": [
          "image_id",
          "image_type",
          "title",
          "image_url",
          "created_at"
        ],
        "properties": {
          "image_id": {
            "type": "string",
            "description": "Unique image identifier.",
            "example": "img_a1b2c3d4e5f6"
          },
          "image_type": {
            "type": "string",
            "enum": [
              "chart",
              "ai_generated",
              "screenshot"
            ],
            "description": "Type of image.",
            "example": "chart"
          },
          "title": {
            "type": "string",
            "description": "Image title.",
            "example": "Illustrative report chart"
          },
          "description": {
            "type": "string",
            "description": "Image description.",
            "example": "Placeholder chart demonstrating a generated image record."
          },
          "image_url": {
            "type": "string",
            "format": "uri",
            "description": "URL to access the image.",
            "example": "https://example.com/reports/illustrative-chart.png"
          },
          "created_at": {
            "type": "integer",
            "description": "Unix timestamp (milliseconds) of image creation.",
            "example": 1718444520000
          },
          "source_url": {
            "type": "string",
            "format": "uri",
            "description": "Original web page URL. Only present when `image_type` is `\"screenshot\"`.",
            "example": "https://example.com/dashboard"
          },
          "captured_at": {
            "type": "integer",
            "description": "Unix timestamp (milliseconds) when the screenshot was taken. Only present when `image_type` is `\"screenshot\"`.",
            "example": 1718444520000
          },
          "chart_kind": {
            "type": "string",
            "description": "Newer chart kind, for example `stacked` or `slope`. Only present when `image_type` is `\"chart\"`. Clients must accept values that they do not know.",
            "example": "slope"
          },
          "chart_type": {
            "type": "string",
            "enum": [
              "line",
              "bar",
              "area",
              "pie",
              "doughnut",
              "radar",
              "scatter",
              "horizontalBar",
              "heatmap",
              "boxplot",
              "stackedBar",
              "stackedArea",
              "histogram",
              "waterfall",
              "timeline",
              "bubble"
            ],
            "description": "Chart type. Only present when `image_type` is `\"chart\"`.",
            "example": "bar"
          },
          "x_axis_label": {
            "type": "string",
            "description": "X-axis label. Only present for chart images.",
            "example": "Trial Phase"
          },
          "y_axis_label": {
            "type": "string",
            "description": "Y-axis label. Only present for chart images.",
            "example": "Number of Trials"
          },
          "data_series": {
            "type": "array",
            "description": "Chart data series. Only present when `image_type` is `\"chart\"`.",
            "items": {
              "type": "object",
              "required": ["name", "data"],
              "properties": {
                "name": {
                  "type": "string",
                  "description": "Series name shown in the legend."
                },
                "data": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": ["x", "y"],
                    "properties": {
                      "x": {
                        "oneOf": [
                          { "type": "string" },
                          { "type": "number" }
                        ],
                        "description": "X-axis value (category or numeric)."
                      },
                      "y": {
                        "type": "number",
                        "description": "Y-axis value."
                      },
                      "y2": {
                        "type": "number",
                        "description": "End value for `timeline` charts (y = start epoch ms, y2 = end epoch ms)."
                      },
                      "z": {
                        "type": "number",
                        "description": "Bubble size for `bubble` charts."
                      },
                      "values": {
                        "type": "array",
                        "items": { "type": "number" },
                        "description": "Raw data points for `boxplot` charts (library computes quartiles)."
                      }
                    }
                  }
                },
                "line_style": {
                  "type": "string",
                  "enum": ["solid", "dashed", "dotted"],
                  "description": "Line style override for `line`/`area` charts."
                }
              }
            }
          }
        }
      },
      "DeepResearchDeliverableResult": {
        "type": "object",
        "description": "A generated deliverable file from a DeepResearch task.",
        "required": [
          "id",
          "request",
          "type",
          "status",
          "title",
          "url",
          "s3_key",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique deliverable identifier.",
            "example": "del_a1b2c3d4e5f6"
          },
          "request": {
            "type": "string",
            "description": "Original deliverable request description.",
            "example": "Extract all company names, founding years, and revenue data into a spreadsheet"
          },
          "type": {
            "type": "string",
            "enum": [
              "csv",
              "xlsx",
              "pptx",
              "docx",
              "pdf",
              "json",
              "html",
              "unknown"
            ],
            "description": "Deliverable file type.",
            "example": "xlsx"
          },
          "status": {
            "type": "string",
            "enum": [
              "completed",
              "failed"
            ],
            "description": "Generation status.",
            "example": "completed"
          },
          "title": {
            "type": "string",
            "description": "Generated filename or title.",
            "example": "company_data.xlsx"
          },
          "description": {
            "type": "string",
            "description": "Description of the deliverable content.",
            "example": "Spreadsheet containing 25 companies with founding years and revenue data"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Token-signed URL to download the file.",
            "example": "https://example.com/deliverables/del_a1b2c3d4e5f6.xlsx?token=..."
          },
          "s3_key": {
            "type": "string",
            "description": "S3 storage key.",
            "example": "deliverables/org_123/del_a1b2c3d4e5f6.xlsx"
          },
          "row_count": {
            "type": "integer",
            "description": "Number of rows. Only present for CSV/XLSX.",
            "example": 25
          },
          "column_count": {
            "type": "integer",
            "description": "Number of columns. Only present for CSV/XLSX.",
            "example": 5
          },
          "error": {
            "type": "string",
            "description": "Error message. Only present when `status` is `\"failed\"`."
          },
          "created_at": {
            "type": "integer",
            "description": "Unix timestamp (milliseconds) of creation.",
            "example": 1718444640000
          }
        }
      },
      "DeepResearchStatusResponse": {
        "type": "object",
        "description": "Full status and results of a DeepResearch task.",
        "required": [
          "deepresearch_id",
          "status",
          "query",
          "mode",
          "created_at"
        ],
        "properties": {
          "deepresearch_id": {
            "type": "string",
            "description": "Unique identifier for the research task.",
            "example": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          },
          "title": {
            "type": "string",
            "nullable": true,
            "description": "Short title for the task, when available."
          },
          "status": {
            "type": "string",
            "description": "Current task status.\n\n- `queued` - Waiting for capacity\n- `running` - Research in progress\n- `awaiting_input` - HITL checkpoint active, waiting for user response\n- `paused` - HITL checkpoint timed out, state saved, respond anytime to resume (your balance must cover the task when it resumes)\n- `completed` - Research finished successfully\n- `failed` - Research failed\n- `cancelled` - Task was cancelled",
            "enum": [
              "queued",
              "running",
              "awaiting_input",
              "paused",
              "completed",
              "failed",
              "cancelled"
            ],
            "example": "completed"
          },
          "query": {
            "type": "string",
            "description": "The original research query.",
            "example": "Comprehensive analysis of CRISPR gene therapy clinical trials"
          },
          "mode": {
            "type": "string",
            "description": "Research mode used for this task. Deprecated for reading the true mode: it keeps only the older values. Use `research_mode`.",
            "enum": [
              "fast",
              "standard",
              "heavy",
              "max"
            ],
            "example": "standard"
          },
          "output_formats": {
            "type": "array",
            "description": "Output formats requested for this task. Deprecated for reading the true formats: it keeps only the older values. Use `research_output_formats`.",
            "items": {
              "oneOf": [
                {
                  "type": "string",
                  "enum": [
                    "markdown",
                    "pdf",
                    "toon"
                  ]
                },
                {
                  "type": "object"
                }
              ]
            },
            "example": [
              "markdown",
              "pdf"
            ]
          },
          "research_mode": {
            "type": "string",
            "description": "The research mode, present only when it is not one of the older values (for example `instant`). The response then leaves out `mode`. Read this field, and use `mode` when it is not present.",
            "enum": ["instant", "fast", "standard", "heavy", "max"],
            "example": "instant"
          },
          "research_output_formats": {
            "type": "array",
            "description": "The output formats, present only when a format is not one of the older values (for example `structured_report`). The response then leaves out `output_formats`. Read this field, and use `output_formats` when it is not present.",
            "items": {"oneOf": [{"type": "string"}, {"type": "object"}]},
            "example": ["markdown", "structured_report"]
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 timestamp of task creation.",
            "example": "2024-06-15T10:30:00.000Z"
          },
          "public": {
            "type": "boolean",
            "description": "Whether the task results are publicly accessible.",
            "example": false
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "description": "Metadata you attached when creating the task (or the batch task)."
          },
          "batch_id": {
            "type": "string",
            "description": "Batch ID if this task belongs to a batch."
          },
          "batch_task_id": {
            "type": "string",
            "description": "User-provided task ID within a batch."
          },
          "progress": {
            "type": "object",
            "description": "Research progress. Present when `status` is `\"running\"`.",
            "properties": {
              "current_step": {
                "type": "integer",
                "example": 5
              },
              "total_steps": {
                "type": "integer",
                "example": 15
              }
            }
          },
          "output_type": {
            "type": "string",
            "description": "Format of the output. Present when `status` is `\"completed\"`.",
            "enum": [
              "markdown",
              "json",
              "toon"
            ],
            "example": "markdown"
          },
          "output": {
            "description": "Research output. Markdown string or JSON object depending on `output_type`. Present when `status` is `\"completed\"` (may be partial on `\"failed\"` or `\"cancelled\"`).",
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "additionalProperties": true
              }
            ]
          },
          "total_word_count": {
            "type": "integer",
            "description": "Word count of the report, when available."
          },
          "sources": {
            "type": "array",
            "description": "Sources used during research. Present when `status` is `\"completed\"`, `\"failed\"`, or `\"cancelled\"`.",
            "items": {
              "$ref": "#/components/schemas/DeepResearchSource"
            }
          },
          "cost": {
            "type": "number",
            "description": "Total cost billed for this task (base mode price + any tool surcharges). Failed tasks are not billed, even if this field is non-zero.",
            "example": 0.625
          },
          "cost_breakdown": {
            "type": "object",
            "description": "Itemized cost breakdown. Only present when the task has completed.",
            "properties": {
              "task": {
                "type": "number",
                "description": "Base task price for the selected mode, e.g. `0.625` for `standard`."
              },
              "screenshots": {
                "type": "number",
                "description": "Screenshot surcharges (8 credits per successful capture). Omitted if 0."
              },
              "code_execution": {
                "type": "number",
                "description": "Code execution surcharges (16 credits per successful run). Omitted if 0."
              },
              "browse": {
                "type": "number",
                "description": "Browser use surcharges (48 credits per successful session). Omitted if 0."
              },
              "deliverables": {
                "type": "number",
                "description": "Deliverable surcharges (55 credits per Excel, PowerPoint or Word file, 100 per HTML file, 15 per extra CSV or JSON file). PDF files are never charged. Omitted if 0."
              }
            },
            "required": ["task"],
            "example": {
              "task": 0.625
            },
            "deprecated": true
          },
          "cost_detail": {
            "type": "object",
            "description": "Line-by-line cost of the task. Use this field as the source of cost detail. Only present when the task has completed.",
            "properties": {
              "base_usd": {"type": "number", "description": "Base task price."},
              "tools": {
                "type": "array",
                "description": "One entry for each tool that has a charge or free units.",
                "items": {
                  "type": "object",
                  "properties": {
                    "item": {"type": "string", "description": "Stable identifier of the charged item."},
                    "label": {"type": "string", "description": "Human-readable name of the item."},
                    "pricing": {"type": "string", "description": "How the item is priced."},
                    "unit": {"type": "string", "description": "The unit that is counted, for example a call or a page."},
                    "units": {"type": "number", "description": "Units used."},
                    "free_units": {"type": "number", "description": "Units that are free."},
                    "billed_units": {"type": "number", "description": "Units that are charged."},
                    "unit_price_usd": {"type": "number", "description": "Price of one unit."},
                    "usd": {"type": "number", "description": "Charge for the item."},
                    "credits": {"type": "number", "description": "Charge for the item in credits."}
                  }
                }
              },
              "datasets": {
                "type": "array",
                "description": "One entry for each dataset that has a charge. Entries have the same fields as `tools`.",
                "items": {"type": "object", "additionalProperties": true}
              },
              "total_usd": {"type": "number", "description": "Total charge."},
              "base_credits": {"type": "number", "description": "Base task price in credits."},
              "total_credits": {"type": "number", "description": "Total charge in credits."}
            }
          },
          "cost_credits": {
            "type": "number",
            "description": "Total cost of the task in credits.",
            "example": 100
          },
          "cost_breakdown_credits": {
            "type": "object",
            "description": "The same keys as `cost_breakdown`, with each value in credits.",
            "additionalProperties": {"type": "number"},
            "example": {"task": 100}
          },
          "tools": {
            "type": "object",
            "description": "Resolved tools configuration for this task.",
            "properties": {
              "code_execution": {
                "type": "object",
                "properties": {
                  "enabled": { "type": "boolean" },
                  "max_calls": { "type": "integer" }
                },
                "description": "Code execution configuration."
              },
              "screenshots": {
                "type": "object",
                "properties": {
                  "enabled": { "type": "boolean" },
                  "max_calls": { "type": "integer" }
                },
                "description": "Screenshots configuration."
              },
              "browser_use": {
                "type": "object",
                "properties": {
                  "enabled": { "type": "boolean" },
                  "max_calls": { "type": "integer" }
                },
                "description": "Browser use configuration."
              },
              "charts": {
                "type": "object",
                "properties": {
                  "enabled": { "type": "boolean" },
                  "max_calls": { "type": "integer" }
                },
                "description": "Chart generation configuration."
              }
            }
          },
          "completed_at": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 timestamp of task completion. Present when `status` is `\"completed\"`.",
            "example": "2024-06-15T10:35:00.000Z"
          },
          "pdf_url": {
            "type": "string",
            "format": "uri",
            "description": "URL to the generated PDF report. Present when `\"pdf\"` was in `output_formats`."
          },
          "images": {
            "type": "array",
            "description": "Images generated during research (charts, AI-generated, screenshots). Present when `status` is `\"completed\"`.",
            "items": {
              "$ref": "#/components/schemas/DeepResearchImage"
            }
          },
          "pending_deliverables": {
            "type": "array",
            "description": "Deliverables that you requested and the task has not produced yet. `deliverables` lists only completed and failed files.",
            "items": {"type": "object", "additionalProperties": true}
          },
          "deliverables": {
            "type": "array",
            "description": "Generated deliverable files (CSV, Excel, PowerPoint, Word, PDF). Lists only completed and failed files. Present when deliverables were requested.",
            "items": {
              "$ref": "#/components/schemas/DeepResearchDeliverableResult"
            }
          },
          "messages": {
            "type": "array",
            "description": "Conversation trace of the research agent. Present when `status` is `\"running\"` or `\"completed\"`.",
            "items": {
              "type": "object",
              "properties": {
                "role": {
                  "type": "string"
                },
                "content": {
                  "type": "string"
                }
              }
            }
          },
          "error": {
            "type": "string",
            "description": "Error message. Present when `status` is `\"failed\"`. Do not use it as your only error signal. Branch on `error_code`."
          },
          "error_code": {
            "type": "string",
            "description": "Stable code for the failure. Present when `status` is `\"failed\"`, next to `error`.",
            "example": "search.sources_not_entitled"
          },
          "warnings": {
            "type": "array",
            "description": "Problems with the request, and brand kit or cover art files that could not be used. Always present, `[]` when there are none. Each entry is an object with `type`, `message` and an optional `detail`, not a string. New warning types may be added at any time. Older tasks may hold plain strings; treat a string as the message. See [Warnings](https://docs.valyu.ai/api-reference/warnings).",
            "items": {
              "oneOf": [
                {
                  "$ref": "#/components/schemas/Warning"
                },
                {
                  "type": "string"
                }
              ]
            }
          },
          "hitl_config": {
            "type": "object",
            "description": "HITL configuration. Present when HITL was enabled on task creation.",
            "properties": {
              "planning_questions": {
                "type": "boolean"
              },
              "plan_review": {
                "type": "boolean"
              },
              "source_review": {
                "type": "boolean"
              },
              "outline_review": {
                "type": "boolean"
              }
            }
          },
          "interaction": {
            "type": "object",
            "description": "Current HITL checkpoint. Present when status is `awaiting_input` or `paused`.",
            "properties": {
              "interaction_id": {
                "type": "string",
                "description": "Unique ID for this interaction. Pass this when responding."
              },
              "type": {
                "type": "string",
                "description": "Checkpoint type.",
                "enum": ["planning_questions", "plan_review", "source_review", "outline_review"]
              },
              "data": {
                "description": "Checkpoint-specific data - shape depends on `type`.",
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/HitlPlanningQuestionsData"
                  },
                  {
                    "$ref": "#/components/schemas/HitlPlanReviewData"
                  },
                  {
                    "$ref": "#/components/schemas/HitlSourceReviewData"
                  },
                  {
                    "$ref": "#/components/schemas/HitlOutlineReviewData"
                  }
                ]
              },
              "created_at": {
                "type": "integer",
                "description": "Unix timestamp (ms) when the checkpoint fired."
              },
              "timeout_ms": {
                "type": "integer",
                "description": "Timeout duration in milliseconds (default 300000 = 5 minutes)."
              },
              "expected_response": {
                "type": "object",
                "description": "Schema hint for the expected response shape.",
                "additionalProperties": true
              }
            }
          },
          "hitl_history": {
            "type": "array",
            "description": "History of completed HITL checkpoints. Present after any checkpoint completes.",
            "items": {
              "type": "object",
              "properties": {
                "interaction_id": {
                  "type": "string"
                },
                "type": {
                  "type": "string",
                  "enum": ["planning_questions", "plan_review", "source_review", "outline_review"]
                },
                "created_at": {
                  "type": "integer",
                  "description": "When the checkpoint fired (ms)."
                },
                "responded_at": {
                  "type": "integer",
                  "description": "When the user responded (ms). Absent if timed out."
                },
                "auto_continued": {
                  "type": "boolean",
                  "description": "True if timed out, false if user responded."
                },
                "response": {
                  "type": "object",
                  "description": "The user's response. Absent if timed out.",
                  "additionalProperties": true
                }
              }
            }
          },
          "editable": {
            "type": "boolean",
            "description": "Whether this completed task supports report editing (completed markdown reports).",
            "example": true
          },
          "version": {
            "type": "integer",
            "minimum": 1,
            "description": "Current head version number, or the requested version when `?version=N` is passed.",
            "example": 2
          },
          "version_count": {
            "type": "integer",
            "minimum": 1,
            "description": "Total number of versions created for this task.",
            "example": 2
          },
          "revised_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "ISO 8601 timestamp of the latest applied edit or restore, when revised.",
            "example": "2026-11-19T14:20:09.000Z"
          },
          "active_edit": {
            "nullable": true,
            "allOf": [
              {
                "$ref": "#/components/schemas/DeepResearchEditAcceptedResponse"
              }
            ],
            "description": "The edit currently running on this task, if any."
          },
          "is_latest": {
            "type": "boolean",
            "description": "Whether the returned snapshot is the current head version. Returned when reading a version via `?version=N`.",
            "example": false
          }
        }
      },
      "DeepResearchListItem": {
        "type": "object",
        "description": "Summary of a DeepResearch task in list view.",
        "required": [
          "deepresearch_id",
          "query",
          "status",
          "created_at"
        ],
        "properties": {
          "deepresearch_id": {
            "type": "string",
            "description": "Unique identifier for the research task.",
            "example": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          },
          "query": {
            "type": "string",
            "description": "The original research query.",
            "example": "CRISPR gene therapy clinical trials"
          },
          "status": {
            "type": "string",
            "description": "Current task status.",
            "enum": [
              "queued",
              "running",
              "completed",
              "failed",
              "cancelled"
            ],
            "example": "completed"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 timestamp of task creation.",
            "example": "2024-06-15T10:30:00.000Z"
          },
          "public": {
            "type": "boolean",
            "description": "Whether the task results are publicly accessible.",
            "example": false
          }
        }
      },
      "DeepResearchUpdateRequest": {
        "type": "object",
        "required": [
          "instruction"
        ],
        "additionalProperties": false,
        "description": "Follow-up instruction to guide a running research task. Can only be sent before the writing phase begins.",
        "properties": {
          "instruction": {
            "type": "string",
            "description": "Follow-up instruction for the research agent.",
            "example": "Also compare the safety profiles across all trials"
          }
        }
      },
      "DeepResearchUpdateResponse": {
        "type": "object",
        "required": [
          "success",
          "message",
          "deepresearch_id"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Whether the operation succeeded.",
            "example": true
          },
          "message": {
            "type": "string",
            "description": "Human-readable status message.",
            "example": "Instruction added"
          },
          "deepresearch_id": {
            "type": "string",
            "description": "ID of the affected task.",
            "example": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          }
        }
      },
      "DeepResearchCancelResponse": {
        "type": "object",
        "required": [
          "success",
          "message",
          "deepresearch_id"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Whether the operation succeeded.",
            "example": true
          },
          "message": {
            "type": "string",
            "description": "Human-readable status message.",
            "example": "Task cancelled"
          },
          "deepresearch_id": {
            "type": "string",
            "description": "ID of the affected task.",
            "example": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          }
        }
      },
      "DeepResearchDeleteResponse": {
        "type": "object",
        "required": [
          "success",
          "message",
          "deepresearch_id"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Whether the operation succeeded.",
            "example": true
          },
          "message": {
            "type": "string",
            "description": "Human-readable status message.",
            "example": "Task deleted successfully"
          },
          "deepresearch_id": {
            "type": "string",
            "description": "ID of the affected task.",
            "example": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          }
        }
      },
      "DeepResearchTogglePublicRequest": {
        "type": "object",
        "required": [
          "public"
        ],
        "additionalProperties": false,
        "description": "Request to toggle the public visibility of a DeepResearch task.",
        "properties": {
          "public": {
            "type": "boolean",
            "description": "Set to `true` to make the task publicly accessible, or `false` to make it private.",
            "example": true
          }
        }
      },
      "DeepResearchTogglePublicResponse": {
        "type": "object",
        "required": [
          "success",
          "message",
          "deepresearch_id",
          "public"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Whether the operation succeeded.",
            "example": true
          },
          "message": {
            "type": "string",
            "description": "Human-readable status message.",
            "example": "Public flag updated"
          },
          "deepresearch_id": {
            "type": "string",
            "description": "ID of the affected task.",
            "example": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          },
          "public": {
            "type": "boolean",
            "description": "The updated public visibility status.",
            "example": true
          }
        }
      },
      "DeepResearchShareEntry": {
        "type": "object",
        "description": "One person or company domain the report is shared with. Each entry has either `email` or `domain`.",
        "required": [
          "added_at"
        ],
        "properties": {
          "email": {
            "type": "string",
            "format": "email",
            "description": "Email address of a person the report is shared with.",
            "example": "anna@client.com"
          },
          "domain": {
            "type": "string",
            "description": "Company domain the report is shared with, without the leading `@`. Covers anyone with a verified email at exactly this domain.",
            "example": "acme.com"
          },
          "added_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the person or domain was added.",
            "example": "2026-11-12T10:30:00.000Z"
          },
          "notified_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the person was last emailed a link. Absent if they were never emailed. Domains are never emailed.",
            "example": "2026-11-12T10:30:01.000Z"
          },
          "last_viewed_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the person last opened the report. Absent if they haven't opened it.",
            "example": "2026-11-12T14:05:00.000Z"
          }
        }
      },
      "DeepResearchSharing": {
        "type": "object",
        "description": "Who the report is shared with. Present when `share_with` was applied.",
        "required": [
          "share_url",
          "shared_with",
          "notified"
        ],
        "properties": {
          "share_url": {
            "type": "string",
            "format": "uri",
            "description": "Link to the report. Viewers sign in to Valyu with an email the report is shared with.",
            "example": "https://platform.valyu.ai/share/a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          },
          "shared_with": {
            "type": "array",
            "description": "People and domains the report is shared with.",
            "items": {
              "$ref": "#/components/schemas/DeepResearchShareEntry"
            }
          },
          "notified": {
            "type": "array",
            "description": "Email addresses that were sent a link to the report.",
            "items": {
              "type": "string",
              "format": "email"
            },
            "example": [
              "anna@client.com"
            ]
          }
        }
      },
      "DeepResearchShareResponse": {
        "type": "object",
        "description": "Who a DeepResearch report is shared with.",
        "required": [
          "deepresearch_id",
          "public",
          "share_url",
          "shared_with"
        ],
        "properties": {
          "deepresearch_id": {
            "type": "string",
            "description": "ID of the task.",
            "example": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          },
          "public": {
            "type": "boolean",
            "description": "Whether anyone with the link can open the report. Set with [Toggle public access](https://docs.valyu.ai/api-reference/endpoint/deepresearch-public). Independent of `shared_with`.",
            "example": false
          },
          "share_url": {
            "type": "string",
            "format": "uri",
            "description": "Link to the report.",
            "example": "https://platform.valyu.ai/share/a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          },
          "shared_with": {
            "type": "array",
            "description": "People and domains the report is shared with.",
            "items": {
              "$ref": "#/components/schemas/DeepResearchShareEntry"
            }
          }
        }
      },
      "DeepResearchShareUpdateRequest": {
        "type": "object",
        "additionalProperties": false,
        "description": "People or company domains to add to or remove from a report. At least one of `add` or `remove` must name someone. Additions and removals apply together or not at all.",
        "properties": {
          "add": {
            "type": "array",
            "description": "Email addresses (`name@company.com`) or company domains (`@company.com`) to share the report with. Public email providers can't be added as a domain.",
            "items": {
              "type": "string"
            },
            "example": [
              "ben@client.com"
            ]
          },
          "remove": {
            "type": "array",
            "description": "Email addresses or company domains to stop sharing the report with, in the same format as `add`.",
            "items": {
              "type": "string"
            },
            "example": [
              "@acme.com"
            ]
          },
          "notify": {
            "type": "boolean",
            "description": "Email each person in `add` a link to the report. Domains are never emailed.",
            "default": true
          },
          "shared_by": {
            "type": "string",
            "maxLength": 80,
            "description": "How the email names the sender. Defaults to your organization's name.",
            "example": "Maya at Northwind Capital"
          }
        }
      },
      "DeepResearchShareUpdateResponse": {
        "type": "object",
        "description": "Who a DeepResearch report is shared with after the change.",
        "required": [
          "deepresearch_id",
          "public",
          "share_url",
          "shared_with",
          "notified"
        ],
        "properties": {
          "deepresearch_id": {
            "type": "string",
            "description": "ID of the task.",
            "example": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          },
          "public": {
            "type": "boolean",
            "description": "Whether anyone with the link can open the report. Set with [Toggle public access](https://docs.valyu.ai/api-reference/endpoint/deepresearch-public). Independent of `shared_with`.",
            "example": false
          },
          "share_url": {
            "type": "string",
            "format": "uri",
            "description": "Link to the report.",
            "example": "https://platform.valyu.ai/share/a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          },
          "shared_with": {
            "type": "array",
            "description": "People and domains the report is shared with.",
            "items": {
              "$ref": "#/components/schemas/DeepResearchShareEntry"
            }
          },
          "notified": {
            "type": "array",
            "description": "Email addresses that were sent a link in this request.",
            "items": {
              "type": "string",
              "format": "email"
            },
            "example": [
              "ben@client.com"
            ]
          }
        }
      },
      "DeepResearchEditTarget": {
        "description": "What to edit: the written report (`{\"kind\": \"report\"}`, default) or a specific deliverable file (`{\"kind\": \"deliverable\", \"deliverable_id\": \"f_01\"}`).",
        "oneOf": [
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "report"
                ],
                "description": "Edit the written markdown report."
              }
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "kind",
              "deliverable_id"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "deliverable"
                ],
                "description": "Edit one of the task's generated deliverable files."
              },
              "deliverable_id": {
                "type": "string",
                "description": "Deliverable ID from the task's `deliverables` list (for example `f_01`, `f_02`).",
                "example": "f_01"
              }
            }
          }
        ]
      },
      "DeepResearchEditFocus": {
        "type": "object",
        "additionalProperties": false,
        "description": "Optional pointer to a passage or section in the report.",
        "properties": {
          "start_char": {
            "type": "integer",
            "minimum": 0,
            "description": "Start UTF-16 offset into the `output` markdown of `base_version`. Must be given together with `end_char`, with `end_char > start_char`.",
            "example": 1840
          },
          "end_char": {
            "type": "integer",
            "minimum": 1,
            "description": "End UTF-16 offset into the `output` markdown of `base_version`. Must be given together with `start_char`, with `end_char > start_char`.",
            "example": 1965
          },
          "text": {
            "type": "string",
            "maxLength": 20000,
            "description": "Highlighted text to focus on. Offsets are trusted when `text` matches; otherwise `text` is searched for and narrowed by `prefix`, `suffix`, `section`, and the offset hint."
          },
          "prefix": {
            "type": "string",
            "maxLength": 2000,
            "description": "Text immediately before the passage to disambiguate matches."
          },
          "suffix": {
            "type": "string",
            "maxLength": 2000,
            "description": "Text immediately after the passage to disambiguate matches."
          },
          "section": {
            "type": "string",
            "minLength": 1,
            "maxLength": 300,
            "description": "Section heading. Sent alone, focuses that whole section.",
            "example": "Executive Summary"
          },
          "scope": {
            "type": "string",
            "enum": [
              "prefer",
              "strict"
            ],
            "default": "prefer",
            "description": "`prefer` points the editor at the focused region (default). `strict` rejects changes outside the focus."
          }
        }
      },
      "DeepResearchEditRequest": {
        "type": "object",
        "additionalProperties": false,
        "description": "Request body for editing a completed DeepResearch report or deliverable. Unknown fields are rejected with `400` `edit.invalid_request`.",
        "required": [
          "instruction"
        ],
        "properties": {
          "instruction": {
            "type": "string",
            "minLength": 1,
            "maxLength": 4000,
            "description": "Plain-English description of the change to make.",
            "example": "Cut the executive summary to 3 bullets and add the Q3 revenue figure with its citation."
          },
          "target": {
            "$ref": "#/components/schemas/DeepResearchEditTarget"
          },
          "focus": {
            "$ref": "#/components/schemas/DeepResearchEditFocus"
          },
          "base_version": {
            "type": "integer",
            "minimum": 1,
            "description": "Version number you are editing. If the task head has moved on, the endpoint returns `409` `edit.revision_conflict`.",
            "example": 1
          },
          "citations": {
            "type": "string",
            "enum": [
              "stable",
              "compact"
            ],
            "default": "stable",
            "description": "`stable` (default) keeps existing citation numbers, appends new citations after the highest used, and retires dropped ones. `compact` renumbers citations by first use."
          },
          "wait_seconds": {
            "type": "number",
            "minimum": 0,
            "maximum": 20,
            "description": "Seconds to wait inline for the edit to finish (0 to 20). Returns `200` with the full edit record if finished in time, otherwise `202`.",
            "example": 15
          }
        }
      },
      "DeepResearchEditDecline": {
        "type": "object",
        "description": "Reason an edit finished with status `declined`.",
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "string",
            "enum": [
              "edit.rewrite_requested",
              "edit.out_of_evidence",
              "edit.contradictory",
              "edit.unsafe_instruction",
              "edit.not_applicable",
              "edit.no_change"
            ],
            "description": "Machine-readable decline code."
          },
          "message": {
            "type": "string",
            "description": "Human-readable explanation of why the edit was declined."
          },
          "suggestion": {
            "type": "string",
            "nullable": true,
            "description": "Suggested next step for the caller or user."
          }
        }
      },
      "DeepResearchEditError": {
        "type": "object",
        "description": "Failure details when an edit finishes with status `failed`.",
        "properties": {
          "code": {
            "type": "string",
            "description": "Stable error code, such as `edit.interrupted` when interrupted by a restart.",
            "example": "edit.interrupted"
          },
          "message": {
            "type": "string",
            "description": "Human-readable failure detail."
          },
          "retryable": {
            "type": "boolean",
            "description": "Whether submitting the edit again may succeed."
          }
        }
      },
      "DeepResearchEditAcceptedResponse": {
        "type": "object",
        "description": "Accepted edit returned with HTTP `202` while the edit is running.",
        "required": [
          "edit_id",
          "deepresearch_id",
          "status",
          "target",
          "base_version",
          "created_at"
        ],
        "properties": {
          "edit_id": {
            "type": "string",
            "description": "Unique identifier for this edit.",
            "example": "ed_01j9x4k2m8n7p3q5r6s8t0v2w4"
          },
          "deepresearch_id": {
            "type": "string",
            "description": "DeepResearch task ID.",
            "example": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          },
          "status": {
            "type": "string",
            "enum": [
              "running"
            ],
            "description": "Current edit status."
          },
          "target": {
            "$ref": "#/components/schemas/DeepResearchEditTarget"
          },
          "base_version": {
            "type": "integer",
            "minimum": 1,
            "description": "Version number the edit was started against."
          },
          "focus": {
            "nullable": true,
            "allOf": [
              {
                "$ref": "#/components/schemas/DeepResearchEditFocus"
              }
            ],
            "description": "Focus supplied in the edit request, if any."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 timestamp when the edit was created."
          },
          "retry_after_seconds": {
            "type": "number",
            "description": "Suggested polling delay in seconds.",
            "example": 3
          }
        }
      },
      "DeepResearchEditRecord": {
        "type": "object",
        "description": "Full record of a DeepResearch edit.",
        "required": [
          "edit_id",
          "deepresearch_id",
          "status",
          "target",
          "base_version",
          "created_at"
        ],
        "properties": {
          "edit_id": {
            "type": "string",
            "description": "Unique identifier for this edit.",
            "example": "ed_01j9x4k2m8n7p3q5r6s8t0v2w4"
          },
          "deepresearch_id": {
            "type": "string",
            "description": "DeepResearch task ID.",
            "example": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          },
          "status": {
            "type": "string",
            "enum": [
              "running",
              "applied",
              "declined",
              "failed"
            ],
            "description": "Lifecycle status of the edit."
          },
          "target": {
            "$ref": "#/components/schemas/DeepResearchEditTarget"
          },
          "base_version": {
            "type": "integer",
            "minimum": 1,
            "description": "Version number the edit was applied against."
          },
          "version": {
            "type": "integer",
            "minimum": 1,
            "nullable": true,
            "description": "New version number created when `status` is `applied`."
          },
          "focus": {
            "nullable": true,
            "allOf": [
              {
                "$ref": "#/components/schemas/DeepResearchEditFocus"
              }
            ],
            "description": "Focus supplied in the edit request, if any."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 timestamp when the edit was created."
          },
          "retry_after_seconds": {
            "type": "number",
            "nullable": true,
            "description": "Suggested polling delay in seconds while `status` is `running`."
          },
          "summary": {
            "type": "string",
            "nullable": true,
            "description": "Short summary of the result."
          },
          "changes": {
            "type": "array",
            "maxItems": 50,
            "description": "The changed blocks of lines, in order, at most 50. Each block gives the 1-based line in the base version's output (the version the edit started from) where it begins, and the whole lines removed and added, at most 40 of each. `stats` counts the full edit even when this list is cut short.",
            "items": {
              "type": "object",
              "required": ["line", "removed", "added"],
              "additionalProperties": false,
              "properties": {
                "line": {
                  "type": "integer",
                  "minimum": 1,
                  "description": "1-based line in the base version's output where the change begins."
                },
                "removed": {
                  "type": "array",
                  "maxItems": 40,
                  "items": { "type": "string" },
                  "description": "Whole lines removed from the base version, in order. Empty for a pure insertion."
                },
                "added": {
                  "type": "array",
                  "maxItems": 40,
                  "items": { "type": "string" },
                  "description": "Whole lines that replace them in the new version, in order. Empty for a pure deletion."
                }
              }
            }
          },
          "unapplied": {
            "type": "array",
            "description": "Parts of the instruction that could not be applied.",
            "items": {
              "oneOf": [
                {
                  "type": "string"
                },
                {
                  "type": "object",
                  "additionalProperties": true
                }
              ]
            }
          },
          "stats": {
            "type": "object",
            "nullable": true,
            "additionalProperties": true,
            "description": "Metrics for the edit (such as replacement count and characters changed)."
          },
          "warnings": {
            "type": "array",
            "description": "Warnings produced by the edit, such as `deliverables_stale` when a report edit runs on a task with deliverable files.",
            "items": {
              "$ref": "#/components/schemas/Warning"
            }
          },
          "decline": {
            "nullable": true,
            "allOf": [
              {
                "$ref": "#/components/schemas/DeepResearchEditDecline"
              }
            ],
            "description": "Present when `status` is `declined`."
          },
          "error": {
            "nullable": true,
            "allOf": [
              {
                "$ref": "#/components/schemas/DeepResearchEditError"
              }
            ],
            "description": "Present when `status` is `failed`."
          },
          "pdf_url": {
            "type": "string",
            "format": "uri",
            "nullable": true,
            "description": "URL to the re-rendered PDF for the new version when the task has a PDF."
          }
        }
      },
      "DeepResearchEditListResponse": {
        "type": "object",
        "description": "List of edits for a DeepResearch task.",
        "required": [
          "deepresearch_id",
          "edits"
        ],
        "properties": {
          "deepresearch_id": {
            "type": "string",
            "description": "DeepResearch task ID.",
            "example": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          },
          "edits": {
            "type": "array",
            "description": "Edit records for the task.",
            "items": {
              "$ref": "#/components/schemas/DeepResearchEditRecord"
            }
          }
        }
      },
      "DeepResearchFocusCandidate": {
        "type": "object",
        "description": "A candidate match returned when `focus` is ambiguous (`422` `focus.ambiguous`).",
        "properties": {
          "start_char": {
            "type": "integer",
            "description": "Start UTF-16 offset in `output`."
          },
          "end_char": {
            "type": "integer",
            "description": "End UTF-16 offset in `output`."
          },
          "section": {
            "type": "string",
            "nullable": true,
            "description": "Section heading containing this candidate."
          },
          "prefix": {
            "type": "string",
            "description": "Surrounding text before this candidate."
          },
          "suffix": {
            "type": "string",
            "description": "Surrounding text after this candidate."
          }
        },
        "additionalProperties": true
      },
      "DeepResearchFocusErrorResponse": {
        "type": "object",
        "description": "Error body for `422` `focus.not_found` or `focus.ambiguous`. Nothing is run.",
        "required": [
          "error",
          "code"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Human-readable error message."
          },
          "code": {
            "type": "string",
            "enum": [
              "focus.not_found",
              "focus.ambiguous"
            ],
            "description": "Focus resolution error code."
          },
          "candidates": {
            "type": "array",
            "description": "Candidate matches to choose from when `code` is `focus.ambiguous`.",
            "items": {
              "$ref": "#/components/schemas/DeepResearchFocusCandidate"
            }
          }
        }
      },
      "DeepResearchVersionItem": {
        "type": "object",
        "description": "A single version entry in a task's version history.",
        "required": [
          "version",
          "kind",
          "created_at",
          "is_head"
        ],
        "properties": {
          "version": {
            "type": "integer",
            "minimum": 1,
            "description": "Version number."
          },
          "kind": {
            "type": "string",
            "enum": [
              "original",
              "edit",
              "restore"
            ],
            "description": "How this version was created."
          },
          "target": {
            "nullable": true,
            "allOf": [
              {
                "$ref": "#/components/schemas/DeepResearchEditTarget"
              }
            ],
            "description": "Target edited to create this version, when applicable."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 timestamp when this version was created."
          },
          "edit_id": {
            "type": "string",
            "nullable": true,
            "description": "Edit ID that created this version, when `kind` is `edit`."
          },
          "instruction": {
            "type": "string",
            "nullable": true,
            "description": "Edit instruction that created this version, when `kind` is `edit`."
          },
          "summary": {
            "type": "string",
            "nullable": true,
            "description": "Summary of changes in this version."
          },
          "stats": {
            "type": "object",
            "nullable": true,
            "additionalProperties": true,
            "description": "Edit statistics for this version, when available."
          },
          "is_head": {
            "type": "boolean",
            "description": "Whether this version is the current head."
          },
          "pdf_url": {
            "type": "string",
            "format": "uri",
            "nullable": true,
            "description": "URL to the PDF for this version, when available."
          }
        }
      },
      "DeepResearchVersionListResponse": {
        "type": "object",
        "description": "Version history for a DeepResearch task.",
        "required": [
          "deepresearch_id",
          "head",
          "versions"
        ],
        "properties": {
          "deepresearch_id": {
            "type": "string",
            "description": "DeepResearch task ID.",
            "example": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          },
          "head": {
            "type": "integer",
            "minimum": 1,
            "description": "Current head version number.",
            "example": 2
          },
          "versions": {
            "type": "array",
            "description": "All versions of the task.",
            "items": {
              "$ref": "#/components/schemas/DeepResearchVersionItem"
            }
          }
        }
      },
      "DeepResearchVersionRestoreResponse": {
        "type": "object",
        "description": "Result of restoring an earlier version as a new head.",
        "required": [
          "version",
          "restored_from"
        ],
        "properties": {
          "version": {
            "type": "integer",
            "minimum": 1,
            "description": "The newly created head version number.",
            "example": 3
          },
          "restored_from": {
            "type": "integer",
            "minimum": 1,
            "description": "The historical version number that was restored.",
            "example": 1
          }
        }
      },
      "BatchCounts": {
        "type": "object",
        "description": "Task count breakdown for a batch.",
        "required": [
          "total",
          "queued",
          "running",
          "completed",
          "failed",
          "cancelled"
        ],
        "properties": {
          "total": {
            "type": "integer",
            "description": "Total number of tasks in the batch.",
            "example": 10
          },
          "queued": {
            "type": "integer",
            "description": "Tasks waiting to start.",
            "example": 3
          },
          "running": {
            "type": "integer",
            "description": "Tasks currently executing.",
            "example": 2
          },
          "completed": {
            "type": "integer",
            "description": "Tasks that finished successfully.",
            "example": 4
          },
          "failed": {
            "type": "integer",
            "description": "Tasks that encountered errors.",
            "example": 1
          },
          "cancelled": {
            "type": "integer",
            "description": "Tasks that were cancelled.",
            "example": 0
          }
        }
      },
      "CreateBatchRequest": {
        "type": "object",
        "additionalProperties": false,
        "description": "Create a new batch for running multiple DeepResearch tasks with shared configuration.",
        "properties": {
          "name": {
            "type": "string",
            "description": "Optional name for the batch.",
            "example": "Q4 Earnings Analysis Batch"
          },
          "mode": {
            "type": "string",
            "description": "Research mode applied to all tasks in the batch.",
            "enum": [
              "fast",
              "standard",
              "heavy",
              "max"
            ],
            "default": "standard"
          },
          "model": {
            "type": "string",
            "deprecated": true,
            "description": "**Deprecated.** Use `mode` instead.",
            "enum": [
              "fast",
              "standard",
              "heavy",
              "max"
            ]
          },
          "output_formats": {
            "type": "array",
            "description": "Output formats applied to all tasks.",
            "items": {
              "oneOf": [
                {
                  "type": "string",
                  "enum": [
                    "markdown",
                    "pdf"
                  ]
                },
                {
                  "type": "object"
                }
              ]
            },
            "default": [
              "markdown"
            ]
          },
          "search": {
            "$ref": "#/components/schemas/SearchConfig"
          },
          "webhook_url": {
            "type": "string",
            "format": "uri",
            "description": "HTTPS URL to receive a webhook when all tasks complete."
          },
          "metadata": {
            "type": "object",
            "description": "Arbitrary key-value metadata.",
            "additionalProperties": {
              "oneOf": [
                {
                  "type": "string"
                },
                {
                  "type": "number"
                },
                {
                  "type": "boolean"
                }
              ]
            }
          }
        }
      },
      "BatchResponse": {
        "type": "object",
        "description": "Batch status and metadata.",
        "required": [
          "batch_id",
          "status",
          "mode",
          "created_at",
          "counts",
          "cost"
        ],
        "properties": {
          "batch_id": {
            "type": "string",
            "description": "Unique batch identifier.",
            "example": "batch_a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          },
          "status": {
            "type": "string",
            "description": "Batch lifecycle status.\n\n- `open` - Batch created, accepting tasks\n- `processing` - Tasks are running\n- `completed` - All tasks finished successfully\n- `completed_with_errors` - All tasks finished, some failed\n- `cancelled` - Batch was cancelled",
            "enum": [
              "open",
              "processing",
              "completed",
              "completed_with_errors",
              "cancelled"
            ],
            "example": "processing"
          },
          "mode": {
            "type": "string",
            "description": "Research mode for all tasks in this batch.",
            "enum": [
              "fast",
              "standard",
              "heavy",
              "max"
            ],
            "example": "standard"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 timestamp of batch creation.",
            "example": "2024-06-15T10:30:00.000Z"
          },
          "name": {
            "type": "string",
            "description": "Human-readable name for the batch.",
            "example": "Q4 Earnings Analysis Batch"
          },
          "output_formats": {
            "type": "array",
            "description": "Output formats configured for all tasks.",
            "items": {
              "oneOf": [
                {
                  "type": "string"
                },
                {
                  "type": "object"
                }
              ]
            },
            "example": [
              "markdown"
            ]
          },
          "search_params": {
            "type": "object",
            "description": "Shared search configuration."
          },
          "counts": {
            "$ref": "#/components/schemas/BatchCounts"
          },
          "cost": {
            "type": "number",
            "description": "Aggregated cost across all tasks.",
            "example": 5.0
          },
          "completed_at": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 timestamp. Present when batch is completed."
          },
          "webhook_secret": {
            "type": "string",
            "description": "HMAC-SHA256 secret. Only present on creation when `webhook_url` was provided."
          }
        }
      },
      "BatchTaskInput": {
        "type": "object",
        "required": [
          "query"
        ],
        "description": "A task to add to a batch.",
        "properties": {
          "query": {
            "type": "string",
            "description": "The research query. Use `query` (preferred) or `input` (deprecated).",
            "example": "Analyze Tesla Q4 2024 earnings and forward guidance"
          },
          "input": {
            "type": "string",
            "deprecated": true,
            "description": "**Deprecated.** Use `query` instead."
          },
          "id": {
            "type": "string",
            "description": "User-provided task identifier within the batch for your own tracking.",
            "example": "task-tesla-q4"
          },
          "strategy": {
            "type": "string",
            "deprecated": true,
            "description": "**Deprecated.** Use `research_strategy` instead."
          },
          "research_strategy": {
            "type": "string",
            "description": "Natural language strategy to guide the research phase for this task."
          },
          "report_format": {
            "type": "string",
            "description": "Natural language instructions for the output format of this task."
          },
          "urls": {
            "type": "array",
            "description": "URLs to include in research context.",
            "items": {
              "type": "string",
              "format": "uri"
            }
          },
          "metadata": {
            "type": "object",
            "description": "Arbitrary metadata for this task.",
            "additionalProperties": {
              "oneOf": [
                {
                  "type": "string"
                },
                {
                  "type": "number"
                },
                {
                  "type": "boolean"
                }
              ]
            }
          }
        }
      },
      "AddBatchTasksRequest": {
        "type": "object",
        "required": [
          "tasks"
        ],
        "additionalProperties": false,
        "description": "Add tasks to an existing batch.",
        "properties": {
          "tasks": {
            "type": "array",
            "description": "Tasks to add. Max 100 per request.",
            "items": {
              "$ref": "#/components/schemas/BatchTaskInput"
            },
            "minItems": 1,
            "maxItems": 100
          }
        }
      },
      "AddBatchTasksResponse": {
        "type": "object",
        "required": [
          "batch_id",
          "added",
          "tasks",
          "counts"
        ],
        "properties": {
          "batch_id": {
            "type": "string",
            "description": "ID of the batch.",
            "example": "batch_a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          },
          "added": {
            "type": "integer",
            "description": "Number of tasks added.",
            "example": 5
          },
          "tasks": {
            "type": "array",
            "description": "Created tasks with their assigned IDs.",
            "items": {
              "type": "object",
              "properties": {
                "task_id": {
                  "type": "string",
                  "description": "User-provided task ID."
                },
                "deepresearch_id": {
                  "type": "string",
                  "description": "System-generated task UUID."
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "queued"
                  ],
                  "example": "queued"
                }
              }
            }
          },
          "counts": {
            "$ref": "#/components/schemas/BatchCounts"
          }
        }
      },
      "BatchTask": {
        "type": "object",
        "description": "A task within a batch. When `include_output=true` is passed to the list tasks endpoint, additional fields (output_type, output, sources, images, pdf_url, deliverables, error, cost) are included.",
        "required": [
          "deepresearch_id",
          "status",
          "query",
          "created_at"
        ],
        "properties": {
          "task_id": {
            "type": "string",
            "description": "User-provided task ID within the batch."
          },
          "deepresearch_id": {
            "type": "string",
            "description": "Unique ID for the research task.",
            "example": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          },
          "status": {
            "type": "string",
            "description": "Current task status.",
            "enum": [
              "queued",
              "running",
              "completed",
              "failed",
              "cancelled"
            ],
            "example": "completed"
          },
          "query": {
            "type": "string",
            "description": "The research query for this task.",
            "example": "Analyze Tesla Q4 2024 earnings"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 timestamp of task creation.",
            "example": "2024-06-15T10:30:00.000Z"
          },
          "completed_at": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 timestamp of task completion. Only present when task is done."
          },
          "output_type": {
            "type": "string",
            "enum": ["markdown", "json", "toon"],
            "description": "Format of the output. Only present when `include_output=true` and task is completed."
          },
          "output": {
            "description": "Research output. Markdown string, parsed JSON object, or null. Only present when `include_output=true`.",
            "example": "## Tesla Q4 2025 Earnings Analysis\n\n..."
          },
          "sources": {
            "type": "array",
            "description": "Sources cited in the research output. Only present when `include_output=true` and task is completed.",
            "items": {
              "type": "object"
            }
          },
          "images": {
            "type": "array",
            "description": "Charts and images generated during research. Only present when `include_output=true` and task produced images.",
            "items": {
              "type": "object"
            }
          },
          "pdf_url": {
            "type": "string",
            "description": "URL to the PDF version of the report. Only present when `include_output=true` and PDF output was requested.",
            "example": "https://example.com/reports/illustrative-report.pdf"
          },
          "deliverables": {
            "type": "array",
            "description": "Generated deliverables (XLSX, PPTX, DOCX). Only present when `include_output=true` and deliverables were produced.",
            "items": {
              "type": "object"
            }
          },
          "error": {
            "type": "string",
            "nullable": true,
            "description": "Error message. Only present when `include_output=true` for failed tasks.",
            "example": "Task exceeded maximum execution time"
          },
          "cost": {
            "type": "number",
            "description": "Cost of this task. Only present when `include_output=true`.",
            "example": 1.0
          }
        }
      },
      "BatchTaskListResponse": {
        "type": "object",
        "required": [
          "batch_id",
          "tasks",
          "pagination"
        ],
        "properties": {
          "batch_id": {
            "type": "string",
            "description": "ID of the batch these tasks belong to.",
            "example": "batch_a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          },
          "tasks": {
            "type": "array",
            "description": "Array of tasks in the batch.",
            "items": {
              "$ref": "#/components/schemas/BatchTask"
            }
          },
          "pagination": {
            "description": "Pagination metadata.",
            "type": "object",
            "required": [
              "count",
              "has_more"
            ],
            "properties": {
              "count": {
                "type": "integer",
                "description": "Number of tasks returned.",
                "example": 10
              },
              "last_key": {
                "type": "string",
                "nullable": true,
                "description": "Cursor for the next page. Pass as `last_key` query parameter. `null` if no more results."
              },
              "has_more": {
                "type": "boolean",
                "example": false
              }
            }
          }
        }
      },
      "CancelBatchResponse": {
        "type": "object",
        "required": [
          "batch_id",
          "status",
          "cancelled_count"
        ],
        "properties": {
          "batch_id": {
            "type": "string",
            "description": "ID of the cancelled batch.",
            "example": "batch_a1b2c3d4-e5f6-7890-abcd-ef1234567890"
          },
          "status": {
            "type": "string",
            "description": "Batch status after cancellation.",
            "enum": [
              "cancelled"
            ],
            "example": "cancelled"
          },
          "cancelled_count": {
            "type": "integer",
            "description": "Number of tasks cancelled.",
            "example": 3
          },
          "name": {"type": "string", "description": "Name of the batch."},
          "mode": {"type": "string", "description": "Research mode of the batch."},
          "counts": {"$ref": "#/components/schemas/BatchCounts"},
          "cost": {"type": "number", "description": "Cost across the tasks of the batch."},
          "created_at": {"type": "string", "format": "date-time", "description": "ISO 8601 timestamp of batch creation."},
          "completed_at": {"type": "string", "format": "date-time", "description": "ISO 8601 timestamp. Present when the batch has finished."},
          "output_formats": {
            "type": "array",
            "description": "Output formats of the batch.",
            "items": {"oneOf": [{"type": "string"}, {"type": "object"}]}
          },
          "results_ready": {"type": "boolean", "description": "Whether the results of the batch are ready."},
          "task_defaults": {"type": "object", "additionalProperties": true, "description": "Shared settings that the tasks of the batch use."}
        }
      },
      "BatchUsage": {
        "type": "object",
        "description": "Aggregated cost breakdown for a batch.",
        "properties": {
          "search_cost": {
            "type": "number",
            "description": "Total search operation cost.",
            "example": 1.5
          },
          "contents_cost": {
            "type": "number",
            "description": "Total content extraction cost.",
            "example": 0.25
          },
          "ai_cost": {
            "type": "number",
            "description": "Total AI processing cost.",
            "example": 3.0
          },
          "total_cost": {
            "type": "number",
            "description": "Total cost across all operations.",
            "example": 4.75
          }
        }
      },
      "Datasource": {
        "type": "object",
        "description": "A data source available through Valyu's search API.",
        "required": [
          "id",
          "name",
          "description",
          "category"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique datasource identifier.",
            "example": "valyu/valyu-arxiv"
          },
          "name": {
            "type": "string",
            "description": "Display name of the datasource.",
            "example": "arXiv"
          },
          "description": {
            "type": "string",
            "description": "What data this source provides.",
            "example": "Preprints in physics, mathematics, computer science, and more."
          },
          "category": {
            "type": "string",
            "description": "Category classification. The live list is returned by `GET /v1/datasources/categories`.",
            "enum": [
              "research",
              "healthcare",
              "patents",
              "markets",
              "company",
              "economic",
              "predictions",
              "transportation",
              "legal",
              "politics"
            ],
            "example": "research"
          },
          "type": {
            "type": "string",
            "description": "Content type (e.g. paper, data, report).",
            "example": "paper"
          },
          "topics": {
            "type": "array",
            "description": "Subject areas covered by this datasource.",
            "items": {
              "type": "string"
            },
            "example": [
              "physics",
              "mathematics",
              "computer science"
            ]
          },
          "languages": {
            "type": "array",
            "description": "Languages supported by this datasource.",
            "items": {
              "type": "string"
            },
            "example": [
              "en",
              "es",
              "fr"
            ]
          },
          "source": {
            "type": "string",
            "description": "Source provider or origin of the datasource.",
            "example": "Publicly available arXiv papers"
          },
          "modality": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Data modalities available (e.g. text, images, tabular).",
            "example": [
              "text"
            ]
          },
          "example_queries": {
            "type": "array",
            "description": "Example queries optimized for few-shot prompting.",
            "items": {
              "type": "string"
            },
            "example": [
              "CRISPR gene editing mechanisms",
              "quantum error correction methods"
            ]
          },
          "pricing": {
            "type": "object",
            "description": "Cost information for this datasource.",
            "properties": {
              "cpm": {
                "type": "number",
                "description": "Price per 1,000 results returned from this datasource. `0` means no price is configured, not that the source is free.",
                "example": 0.3125
              }
            }
          },
          "required_plan": {
            "type": "object",
            "nullable": true,
            "description": "The cheapest plan that includes this dataset. `null` when the dataset is licensed separately; contact us for access.",
            "properties": {
              "id": {
                "type": "string",
                "description": "Plan ID: `tier_0` Pay-as-you-go, `tier_1` Ridiculously Cheap, `tier_2` Comfortably Pro, `tier_3` Serious Business.",
                "example": "tier_1"
              },
              "name": {
                "type": "string",
                "example": "Ridiculously Cheap"
              },
              "price": {
                "type": "string",
                "example": "$29/mo"
              }
            }
          },
          "access_modes": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "search",
                "answer",
                "deepresearch"
              ]
            },
            "description": "Products this datasource can be used in. A datasource without `search` can't be queried through Search; one listing only `deepresearch` is available only through DeepResearch.",
            "example": [
              "search",
              "answer",
              "deepresearch"
            ]
          },
          "response_schema": {
            "type": "object",
            "description": "JSON Schema describing the response format for results from this source.",
            "additionalProperties": true
          },
          "update_frequency": {
            "type": "string",
            "description": "How often the data is updated (Realtime, Daily, Monthly).",
            "example": "Monthly"
          },
          "size": {
            "type": "integer",
            "description": "Approximate number of records or documents.",
            "example": 1000000
          },
          "coverage": {
            "type": "object",
            "description": "Temporal coverage of the data.",
            "properties": {
              "start_date": {
                "type": "string",
                "format": "date-time",
                "description": "Earliest data available."
              },
              "end_date": {
                "type": "string",
                "format": "date-time",
                "nullable": true,
                "description": "Latest data available. `null` if continuously updated."
              }
            }
          },
          "geography": {
            "type": "object",
            "description": "Geographic coverage information, if available.",
            "additionalProperties": true
          },
          "capabilities": {
            "type": "object",
            "description": "Search capabilities supported by this datasource.",
            "additionalProperties": true
          },
          "data_source": {
            "type": "object",
            "description": "Data provider information.",
            "properties": {
              "provider": {
                "type": "string"
              },
              "license": {
                "type": "string"
              }
            }
          }
        }
      },
      "DatasourceCategory": {
        "type": "object",
        "description": "A category of data sources.",
        "required": [
          "id",
          "name",
          "description"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique category identifier.",
            "example": "research"
          },
          "name": {
            "type": "string",
            "description": "Display name of the category.",
            "example": "Research"
          },
          "description": {
            "type": "string",
            "description": "What this category covers.",
            "example": "Academic papers, preprints, and scholarly articles."
          },
          "dataset_count": {
            "type": "integer",
            "description": "Number of datasets in this category.",
            "example": 8
          }
        }
      },
      "DatasourcesResponse": {
        "type": "object",
        "required": [
          "success",
          "datasources"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Whether the request succeeded.",
            "example": true
          },
          "datasources": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Datasource"
            },
            "description": "List of available datasources."
          },
          "total_count": {
            "type": "integer",
            "description": "Total number of datasources returned.",
            "example": 36
          },
          "categories": {
            "type": "object",
            "description": "Summary of categories with counts.",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "count": {
                  "type": "integer"
                }
              }
            }
          }
        }
      },
      "DatasourceCategoriesResponse": {
        "type": "object",
        "required": [
          "success",
          "categories"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Whether the request succeeded.",
            "example": true
          },
          "categories": {
            "type": "array",
            "description": "Array of available datasource categories.",
            "items": {
              "$ref": "#/components/schemas/DatasourceCategory"
            }
          }
        }
      },
      "DatasourceSearchResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "query": {
            "type": "string",
            "description": "The query as interpreted."
          },
          "search_mode": {
            "type": "string",
            "enum": [
              "semantic",
              "lexical"
            ],
            "description": "`semantic` when embedding-based ranking was used; `lexical` when the full-text fallback served the request."
          },
          "total_count": {
            "type": "integer"
          },
          "results": {
            "type": "array",
            "items": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/Datasource"
                },
                {
                  "type": "object",
                  "properties": {
                    "relevance_score": {
                      "type": "number",
                      "minimum": 0,
                      "maximum": 1,
                      "description": "Ranking score, best-first."
                    }
                  }
                }
              ]
            }
          }
        }
      },
      "HitlPlanningQuestionsData": {
        "type": "object",
        "title": "Planning Questions Data",
        "description": "Interaction data for the `planning_questions` checkpoint. Contains clarifying questions the agent wants answered before starting research.",
        "required": ["questions"],
        "properties": {
          "questions": {
            "type": "array",
            "description": "List of clarifying questions.",
            "items": {
              "type": "object",
              "required": ["question"],
              "properties": {
                "question": {
                  "type": "string",
                  "description": "The question text.",
                  "example": "What geographic regions should the research focus on?"
                },
                "context": {
                  "type": "string",
                  "description": "Optional context explaining why this question matters.",
                  "example": "The query mentions global markets, so narrowing the scope improves depth"
                }
              }
            }
          }
        }
      },
      "HitlPlanReviewData": {
        "type": "object",
        "title": "Plan Review Data",
        "description": "Interaction data for the `plan_review` checkpoint. Contains the research plan for user approval.",
        "required": ["plan"],
        "properties": {
          "plan": {
            "type": "string",
            "description": "The proposed research plan.",
            "example": "I'll research this topic by first examining market size data, then analyzing the competitive landscape..."
          },
          "estimated_steps": {
            "type": "integer",
            "description": "Estimated number of research steps.",
            "example": 15
          },
          "research_areas": {
            "type": "array",
            "description": "Key areas the research will cover.",
            "items": {
              "type": "string"
            },
            "example": ["Market size analysis", "Competitive landscape", "Regulatory environment"]
          }
        }
      },
      "HitlSourceReviewData": {
        "type": "object",
        "title": "Source Review Data",
        "description": "Interaction data for the `source_review` checkpoint. Contains sources grouped by domain for user filtering.",
        "required": ["domains", "total_sources"],
        "properties": {
          "domains": {
            "type": "array",
            "description": "Sources grouped by domain.",
            "items": {
              "type": "object",
              "required": ["domain", "source_count", "avg_relevance_score", "sources", "ai_recommendation"],
              "properties": {
                "domain": {
                  "type": "string",
                  "description": "Domain name.",
                  "example": "sec.gov"
                },
                "source_count": {
                  "type": "integer",
                  "description": "Number of sources from this domain.",
                  "example": 8
                },
                "avg_relevance_score": {
                  "type": "number",
                  "description": "Average relevance score (0-1).",
                  "example": 0.87
                },
                "sources": {
                  "type": "array",
                  "description": "Individual sources from this domain.",
                  "items": {
                    "type": "object",
                    "properties": {
                      "source_id": {
                        "type": "integer"
                      },
                      "title": {
                        "type": "string"
                      },
                      "url": {
                        "type": "string",
                        "format": "uri"
                      },
                      "relevance_score": {
                        "type": "number"
                      }
                    }
                  }
                },
                "ai_recommendation": {
                  "type": "string",
                  "description": "AI's recommendation for this domain.",
                  "enum": ["include", "exclude"],
                  "example": "include"
                }
              }
            }
          },
          "total_sources": {
            "type": "integer",
            "description": "Total number of sources across all domains.",
            "example": 42
          }
        }
      },
      "HitlOutlineReviewData": {
        "type": "object",
        "title": "Outline Review Data",
        "description": "Interaction data for the `outline_review` checkpoint. Contains the proposed outline of the report. The report uses the approved sections as its main headings, in the same order.",
        "required": ["outline", "sections"],
        "properties": {
          "outline": {
            "type": "string",
            "description": "The proposed outline as numbered lines. A short description of the section follows the title.",
            "example": "1. Launch history - When each probe flew and on which rocket.\n2. Science targets - Which moons each probe studies and why.\n3. Comparison - How the two missions differ and where they overlap."
          },
          "sections": {
            "type": "array",
            "description": "The sections of the outline, in report order. If the outline cannot be prepared, the array holds one section with the title `Report`. The task then writes the report as usual.",
            "items": {
              "type": "object",
              "required": ["title", "description", "estimated_length"],
              "properties": {
                "title": {
                  "type": "string",
                  "description": "The section heading.",
                  "example": "Science targets"
                },
                "description": {
                  "type": "string",
                  "description": "One sentence on what the section covers.",
                  "example": "Which moons each probe studies and why."
                },
                "estimated_length": {
                  "type": "string",
                  "description": "The planned length of the section.",
                  "enum": ["short", "medium", "long"],
                  "example": "long"
                },
                "weight": {
                  "type": "integer",
                  "description": "Relative importance of the section, from 1 to 5.",
                  "minimum": 1,
                  "maximum": 5,
                  "example": 4
                },
                "depth": {
                  "type": "string",
                  "description": "How deep the section goes.",
                  "enum": ["brief", "standard", "deep"],
                  "example": "deep"
                },
                "nodes": {
                  "type": "integer",
                  "description": "The number of research topics that supply evidence for the section.",
                  "example": 1
                }
              }
            }
          },
          "write_plan": {
            "$ref": "#/components/schemas/HitlWritePlan"
          }
        }
      },
      "HitlWritePlan": {
        "type": "object",
        "title": "Write Plan",
        "description": "The outline as an object that you can edit and send back in the `write_plan` field of the `outline_review` response. Copy the object from the review data and change it. The `nodes` values in each section are identifiers that you must copy from the review data.",
        "required": ["sections", "exclude", "open_questions"],
        "properties": {
          "sections": {
            "type": "array",
            "description": "The sections of the report, in order. At least one section.",
            "minItems": 1,
            "items": {
              "type": "object",
              "required": ["title", "nodes", "weight", "depth"],
              "properties": {
                "title": {
                  "type": "string",
                  "description": "The section heading."
                },
                "nodes": {
                  "type": "array",
                  "description": "The research topics that supply evidence for the section. At least one. Copy the values from the review data.",
                  "minItems": 1,
                  "items": {
                    "type": "string"
                  },
                  "example": ["n_00"]
                },
                "weight": {
                  "type": "integer",
                  "description": "Relative importance of the section, from 1 to 5.",
                  "minimum": 1,
                  "maximum": 5
                },
                "depth": {
                  "type": "string",
                  "description": "How deep the section goes.",
                  "enum": ["brief", "standard", "deep"]
                },
                "description": {
                  "type": "string",
                  "description": "One sentence on what the section covers. Maximum 400 characters.",
                  "minLength": 1,
                  "maxLength": 400
                },
                "estimated_length": {
                  "type": "string",
                  "description": "The planned length of the section.",
                  "enum": ["short", "medium", "long"]
                },
                "must_cite": {
                  "type": "array",
                  "description": "Documents that the section must cite. Copy the identifiers from the review data.",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "exclude": {
            "type": "array",
            "description": "Documents to leave out of the report, with the reason. Send `[]` to exclude none.",
            "items": {
              "type": "object",
              "required": ["id", "reason"],
              "properties": {
                "id": {
                  "type": "string",
                  "description": "The document identifier."
                },
                "reason": {
                  "type": "string",
                  "description": "Why the document is left out."
                }
              }
            }
          },
          "open_questions": {
            "type": "array",
            "description": "Questions that the research could not settle. The report states them. Send `[]` if there are none.",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "HitlPlanningQuestionsResponse": {
        "type": "object",
        "title": "Planning Questions Response",
        "description": "Response shape for the `planning_questions` checkpoint. Provide answers to each clarifying question.",
        "required": ["answers"],
        "properties": {
          "answers": {
            "type": "array",
            "description": "Answers to each question.",
            "items": {
              "type": "object",
              "required": ["question", "answer"],
              "properties": {
                "question": {
                  "type": "string",
                  "description": "The original question text.",
                  "example": "What geographic regions should the research focus on?"
                },
                "answer": {
                  "type": "string",
                  "description": "Your answer.",
                  "example": "North America and EU"
                }
              }
            }
          }
        }
      },
      "HitlPlanReviewResponse": {
        "type": "object",
        "title": "Plan Review Response",
        "description": "Response shape for the `plan_review` checkpoint. Approve the plan or request modifications.",
        "required": ["approved"],
        "properties": {
          "approved": {
            "type": "boolean",
            "description": "Whether to approve the plan.",
            "example": true
          },
          "modifications": {
            "type": "string",
            "description": "Free-text guidance for the model. Only used when `approved` is `false`.",
            "example": "Focus more on battery supply chains and less on historical context"
          }
        }
      },
      "HitlSourceReviewResponse": {
        "type": "object",
        "title": "Source Review Response",
        "description": "Response shape for the `source_review` checkpoint. Specify which domains to include or exclude. Domains not listed in either array fall back to the AI recommendation.",
        "required": ["included_domains", "excluded_domains"],
        "properties": {
          "included_domains": {
            "type": "array",
            "description": "Domains to include. Pass empty `[]` to accept all AI recommendations.",
            "items": {
              "type": "string"
            },
            "example": ["sec.gov", "plos.org"]
          },
          "excluded_domains": {
            "type": "array",
            "description": "Domains to exclude. Pass empty `[]` to not exclude any.",
            "items": {
              "type": "string"
            },
            "example": ["example.com"]
          }
        }
      },
      "HitlOutlineReviewResponse": {
        "type": "object",
        "title": "Outline Review Response",
        "description": "Response shape for the `outline_review` checkpoint. Approve the outline, describe changes in text, send an edited `write_plan`, or combine these. Send `approved`, `write_plan`, or both. If the edited `write_plan` is not valid (for example, a section has no evidence), the task uses the proposed outline. The report uses the approved sections as its main headings, in the same order.",
        "properties": {
          "approved": {
            "type": "boolean",
            "description": "Whether to approve the outline as shown. Required unless you send `write_plan`.",
            "example": true
          },
          "modifications": {
            "type": "string",
            "description": "Written changes to the outline. The report follows the outline and then applies these changes. Maximum 8,000 characters.",
            "maxLength": 8000,
            "example": "Add a section on regulatory risks between Market Analysis and Competitive Landscape"
          },
          "write_plan": {
            "$ref": "#/components/schemas/HitlWritePlan"
          }
        }
      },
      "WorkflowMode": {
        "type": "string",
        "description": "Recommended DeepResearch mode for a workflow. Maps directly to the DeepResearch `mode` parameter.",
        "enum": [
          "fast",
          "standard",
          "heavy",
          "max"
        ],
        "example": "heavy"
      },
      "WorkflowVariableType": {
        "type": "string",
        "description": "Input type for a workflow template variable. Controls how the variable is rendered and validated.",
        "enum": [
          "text",
          "textarea",
          "number",
          "date",
          "enum"
        ],
        "example": "text"
      },
      "WorkflowVariable": {
        "type": "object",
        "description": "A typed variable referenced by `{key}` placeholders in the workflow prompt template.",
        "required": [
          "key",
          "label"
        ],
        "properties": {
          "key": {
            "type": "string",
            "description": "Unique key for the variable. Used as the `{key}` placeholder in the template and as the field name in `workflow_params`.",
            "example": "company"
          },
          "label": {
            "type": "string",
            "description": "Human-readable label for the variable.",
            "example": "Company name"
          },
          "type": {
            "$ref": "#/components/schemas/WorkflowVariableType"
          },
          "required": {
            "type": "boolean",
            "description": "Whether a value must be supplied for this variable.",
            "default": false
          },
          "placeholder": {
            "type": "string",
            "description": "Placeholder text shown in the input field.",
            "example": "NVIDIA (NVDA)"
          },
          "help": {
            "type": "string",
            "description": "Help text explaining what to enter.",
            "example": "The company you want to profile."
          },
          "examples": {
            "type": "array",
            "description": "Example values for the variable.",
            "items": {
              "type": "string"
            },
            "example": ["NVIDIA (NVDA)", "Microsoft (MSFT)"]
          },
          "validation": {
            "type": "object",
            "description": "Validation rules applied to the variable's value.",
            "properties": {
              "min_length": {
                "type": "integer",
                "description": "Minimum string length.",
                "minimum": 0
              },
              "max_length": {
                "type": "integer",
                "description": "Maximum string length.",
                "minimum": 1
              },
              "pattern": {
                "type": "string",
                "description": "Regular expression the value must match."
              },
              "enum": {
                "type": "array",
                "description": "Allowed values when `type` is `enum`.",
                "items": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "WorkflowDeliverable": {
        "type": "object",
        "description": "A deliverable file the workflow produces.",
        "required": [
          "type",
          "description"
        ],
        "properties": {
          "type": {
            "type": "string",
            "description": "File format for the deliverable.",
            "enum": [
              "csv",
              "xlsx",
              "pptx",
              "docx",
              "pdf"
            ],
            "example": "xlsx"
          },
          "description": {
            "type": "string",
            "description": "What the deliverable should contain.",
            "example": "A model summary tab with revenue, margins, and key ratios."
          }
        }
      },
      "WorkflowTools": {
        "type": "object",
        "description": "Optional tools the workflow's research agent may use.",
        "properties": {
          "code_execution": {
            "type": "boolean",
            "description": "Enable code execution in a sandboxed environment."
          },
          "screenshots": {
            "type": "boolean",
            "description": "Enable visual screenshot capture of web pages."
          },
          "browser_use": {
            "type": "boolean",
            "description": "Enable autonomous browser sessions."
          },
          "charts": {
            "type": "boolean",
            "description": "Enable chart and graph generation in the report."
          }
        }
      },
      "WorkflowOutputFormats": {
        "type": "array",
        "description": "Output formats the workflow produces. Items are the strings `\"markdown\"`, `\"pdf\"`, or `\"toon\"`, and/or a single JSON Schema object for structured output. Rules: at most one JSON Schema object; a JSON Schema object cannot be combined with `\"markdown\"` or `\"pdf\"`; `\"toon\"` requires a JSON Schema object. An invalid combination returns `400 invalid_output_formats`.\n\nAt run time, a task created with `workflow_id` inherits the workflow's `output_formats` when the request does not pass its own; a request-level `output_formats` always wins.",
        "items": {
          "oneOf": [
            {
              "type": "string",
              "enum": [
                "markdown",
                "pdf",
                "toon"
              ]
            },
            {
              "type": "object",
              "description": "JSON Schema for structured output."
            }
          ]
        },
        "example": [
          {
            "type": "object",
            "properties": {
              "base_case": { "type": "string" },
              "bull_case": { "type": "string" },
              "bear_case": { "type": "string" },
              "confidence": { "type": "number" }
            }
          },
          "toon"
        ]
      },
      "Workflow": {
        "type": "object",
        "description": "A workflow: templated, versioned DeepResearch. Valyu-curated workflows (`is_valyu: true`) are read-only.\n\nList rows carry the discovery and template fields below. When fetching a single workflow (`GET /v1/workflows/{slug}`), creating, or updating, the response also includes the resolved version body - `prompt`, `strategy`, `report_format`, `tools`, `changelog`, and `output_formats`. On list, those version-body fields are included only when `?expand=true`.",
        "required": [
          "slug",
          "title",
          "version"
        ],
        "properties": {
          "slug": {
            "type": "string",
            "description": "Unique slug identifying the workflow within its scope. Used as `workflow_id` when running.",
            "example": "ib-company-profile"
          },
          "version": {
            "type": "integer",
            "description": "The current (floating) published version number.",
            "minimum": 1,
            "example": 1
          },
          "vertical": {
            "type": "string",
            "nullable": true,
            "description": "Vertical the workflow targets (e.g. `investment-banking`, `private-equity`, `hedge-funds`, `consulting`, `life-sciences`, `legal-regulatory`, `sales-intelligence`, `supply-chain`).",
            "example": "investment-banking"
          },
          "tags": {
            "type": "array",
            "description": "Tags for discovery. Up to 20.",
            "items": {
              "type": "string"
            },
            "maxItems": 20,
            "example": ["company-profile", "equities"]
          },
          "title": {
            "type": "string",
            "description": "Display title.",
            "example": "Company Profile"
          },
          "subtitle": {
            "type": "string",
            "nullable": true,
            "description": "Short subtitle.",
            "example": "One-page profile of a public company."
          },
          "description": {
            "type": "string",
            "nullable": true,
            "description": "Longer description of what the workflow does.",
            "example": "Builds a company profile covering business, financials, and recent developments."
          },
          "popular": {
            "type": "boolean",
            "description": "Whether the workflow is flagged as popular.",
            "example": true
          },
          "recommended_mode": {
            "$ref": "#/components/schemas/WorkflowMode"
          },
          "estimated_time": {
            "type": "string",
            "nullable": true,
            "description": "Human-readable estimate of how long a run takes.",
            "example": "10-20 min"
          },
          "is_valyu": {
            "type": "boolean",
            "description": "Whether this is a Valyu-curated workflow (read-only to users).",
            "example": true
          },
          "owner_org_id": {
            "type": "string",
            "nullable": true,
            "description": "Organization that owns the workflow. `null` for Valyu-curated workflows.",
            "example": null
          },
          "variables": {
            "type": "array",
            "description": "Typed variables referenced by the prompt template. Up to 50.",
            "items": {
              "$ref": "#/components/schemas/WorkflowVariable"
            },
            "maxItems": 50
          },
          "deliverables": {
            "type": "array",
            "description": "Deliverables the workflow produces. Up to 20.",
            "items": {
              "$ref": "#/components/schemas/WorkflowDeliverable"
            },
            "maxItems": 20
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the workflow was created.",
            "example": "2026-01-10T12:00:00Z"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the workflow's current version was last published.",
            "example": "2026-01-15T09:30:00Z"
          },
          "prompt": {
            "type": "string",
            "description": "Prompt template with `{key}` placeholders. Included on detail (get/create/update) and on list with `?expand=true`.",
            "example": "Build a company profile for {company} covering its business, financials, and recent developments."
          },
          "strategy": {
            "type": "string",
            "nullable": true,
            "description": "Research strategy. Maps to DeepResearch `research_strategy`. Included on detail and on list with `?expand=true`."
          },
          "report_format": {
            "type": "string",
            "nullable": true,
            "description": "Report format instructions. Maps to DeepResearch `report_format`. Included on detail and on list with `?expand=true`."
          },
          "tools": {
            "$ref": "#/components/schemas/WorkflowTools"
          },
          "changelog": {
            "type": "string",
            "nullable": true,
            "description": "Changelog for the current version. Included on detail and on list with `?expand=true`."
          },
          "output_formats": {
            "$ref": "#/components/schemas/WorkflowOutputFormats"
          }
        }
      },
      "WorkflowResponse": {
        "description": "A single workflow returned as a flat object: the list-row fields plus the resolved version body (`prompt`, `strategy`, `report_format`, `tools`, `changelog`, `output_formats`). Returned by get, create (`201`), and update.",
        "$ref": "#/components/schemas/Workflow"
      },
      "WorkflowListResponse": {
        "type": "object",
        "description": "List of workflows.",
        "required": [
          "workflows",
          "total"
        ],
        "properties": {
          "workflows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Workflow"
            }
          },
          "total": {
            "type": "integer",
            "description": "Total number of workflows matching the filter.",
            "example": 44
          },
          "next_cursor": {
            "type": "string",
            "nullable": true,
            "description": "Pagination cursor for the next page, or `null` when there are no more results.",
            "example": null
          },
          "verticals": {
            "type": "array",
            "description": "Distinct verticals present across the curated catalog.",
            "items": {
              "type": "string"
            },
            "example": [
              "consulting",
              "private-equity",
              "life-sciences",
              "investment-banking",
              "hedge-funds",
              "legal-regulatory",
              "sales-intelligence",
              "supply-chain"
            ]
          }
        }
      },
      "WorkflowVersionListResponse": {
        "type": "object",
        "description": "A workflow's version history, newest first.",
        "required": [
          "slug",
          "versions"
        ],
        "properties": {
          "slug": {
            "type": "string",
            "example": "ib-company-profile"
          },
          "versions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowVersionSummary"
            }
          }
        }
      },
      "WorkflowVersionSummary": {
        "type": "object",
        "description": "A row in a workflow's version history.",
        "required": [
          "version"
        ],
        "properties": {
          "version": {
            "type": "integer",
            "minimum": 1,
            "example": 2
          },
          "recommended_mode": {
            "$ref": "#/components/schemas/WorkflowMode"
          },
          "estimated_time": {
            "type": "string",
            "nullable": true,
            "example": "10-20 min"
          },
          "changelog": {
            "type": "string",
            "nullable": true,
            "example": "Added a competitive landscape section."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "example": "2026-01-15T09:30:00Z"
          },
          "is_current": {
            "type": "boolean",
            "example": true
          }
        }
      },
      "WorkflowPreviewRequest": {
        "type": "object",
        "description": "Resolve a workflow template against supplied parameters without running it.",
        "properties": {
          "workflow_params": {
            "type": "object",
            "description": "Values for the workflow's template variables, keyed by variable `key`.",
            "additionalProperties": {
              "oneOf": [
                { "type": "string" },
                { "type": "number" },
                { "type": "boolean" }
              ]
            },
            "example": {
              "company": "NVIDIA (NVDA)"
            }
          },
          "workflow_version": {
            "type": "integer",
            "description": "Version to preview. Defaults to the current version.",
            "minimum": 1,
            "example": 1
          }
        }
      },
      "WorkflowPreviewResponse": {
        "type": "object",
        "description": "The resolved configuration a run with these parameters would use.",
        "required": [
          "workflow",
          "resolved"
        ],
        "properties": {
          "workflow": {
            "type": "object",
            "description": "Which workflow and version were resolved.",
            "properties": {
              "slug": {
                "type": "string",
                "example": "ib-company-profile"
              },
              "version": {
                "type": "integer",
                "minimum": 1,
                "example": 1
              }
            }
          },
          "resolved": {
            "type": "object",
            "description": "The resolved DeepResearch configuration.",
            "properties": {
              "input": {
                "type": "string",
                "description": "The prompt template with all `{key}` placeholders substituted.",
                "example": "Build a company profile for NVIDIA (NVDA) covering its business, financials, and recent developments."
              },
              "research_strategy": {
                "type": "string",
                "nullable": true,
                "description": "Resolved research strategy."
              },
              "report_format": {
                "type": "string",
                "nullable": true,
                "description": "Resolved report format."
              },
              "deliverables": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/WorkflowDeliverable"
                }
              },
              "mode": {
                "$ref": "#/components/schemas/WorkflowMode"
              },
              "tools": {
                "$ref": "#/components/schemas/WorkflowTools"
              },
              "output_formats": {
                "$ref": "#/components/schemas/WorkflowOutputFormats"
              }
            }
          },
          "estimated_credits": {
            "type": "number",
            "nullable": true,
            "description": "Estimated credit cost of a run, when available.",
            "example": null
          }
        }
      },
      "WorkflowVersionInput": {
        "type": "object",
        "description": "A workflow version body. Supplied as `version` when creating a workflow or publishing a new version on update.",
        "required": [
          "prompt",
          "strategy",
          "report_format"
        ],
        "properties": {
          "prompt": {
            "type": "string",
            "description": "Prompt template with `{key}` placeholders. Up to 64 KB.",
            "example": "Build a company profile for {company} covering its business, financials, and recent developments."
          },
          "strategy": {
            "type": "string",
            "description": "Research strategy. Maps to DeepResearch `research_strategy`. Up to 64 KB.",
            "example": "Prioritise the latest 10-K/10-Q, investor relations materials, and reputable news."
          },
          "report_format": {
            "type": "string",
            "description": "Report format instructions. Maps to DeepResearch `report_format`. Up to 64 KB.",
            "example": "A one-page profile with business overview, key financials, and recent developments."
          },
          "variables": {
            "type": "array",
            "description": "Typed template variables. Up to 50.",
            "items": {
              "$ref": "#/components/schemas/WorkflowVariable"
            },
            "maxItems": 50
          },
          "deliverables": {
            "type": "array",
            "description": "Deliverables produced by the workflow. Up to 20.",
            "items": {
              "$ref": "#/components/schemas/WorkflowDeliverable"
            },
            "maxItems": 20
          },
          "tools": {
            "$ref": "#/components/schemas/WorkflowTools"
          },
          "recommended_mode": {
            "$ref": "#/components/schemas/WorkflowMode"
          },
          "estimated_time": {
            "type": "string",
            "example": "10-20 min"
          },
          "output_formats": {
            "$ref": "#/components/schemas/WorkflowOutputFormats"
          },
          "changelog": {
            "type": "string",
            "description": "Notes describing what changed. Required when publishing a new version on update.",
            "example": "Added a competitive landscape section."
          }
        }
      },
      "WorkflowCreateRequest": {
        "type": "object",
        "description": "Create an organization workflow. The authenticated org owns the workflow. Default org quota is 100 workflows. The first version is supplied as the nested `version` object.",
        "required": [
          "slug",
          "title",
          "version"
        ],
        "properties": {
          "slug": {
            "type": "string",
            "description": "Unique slug within your org.",
            "example": "quarterly-company-profile"
          },
          "title": {
            "type": "string",
            "example": "Quarterly Company Profile"
          },
          "subtitle": {
            "type": "string",
            "example": "One-page profile of a public company."
          },
          "description": {
            "type": "string",
            "example": "Builds a company profile covering business, financials, and recent developments."
          },
          "vertical": {
            "type": "string",
            "example": "investment-banking"
          },
          "tags": {
            "type": "array",
            "items": { "type": "string" },
            "maxItems": 20,
            "example": ["company-profile", "equities"]
          },
          "icon": {
            "type": "string",
            "example": "building"
          },
          "version": {
            "description": "The workflow's first version body.",
            "$ref": "#/components/schemas/WorkflowVersionInput"
          }
        }
      },
      "WorkflowUpdateRequest": {
        "type": "object",
        "description": "Edit an organization workflow. Metadata fields (title, subtitle, etc.) update in place. Supply a `version` object to publish a new immutable version - it requires a `changelog`. Valyu-curated workflows cannot be edited (`cannot_edit_valyu_workflow`).",
        "properties": {
          "title": { "type": "string" },
          "subtitle": { "type": "string" },
          "description": { "type": "string" },
          "vertical": { "type": "string" },
          "tags": {
            "type": "array",
            "items": { "type": "string" },
            "maxItems": 20
          },
          "icon": { "type": "string" },
          "version": {
            "description": "A new version body to publish. Requires `changelog` (`changelog_required` otherwise).",
            "$ref": "#/components/schemas/WorkflowVersionInput"
          },
          "set_current": {
            "type": "boolean",
            "description": "When publishing a new version, whether to point the workflow's current (floating) version at it.",
            "example": true
          }
        }
      },
      "WorkflowDeleteResponse": {
        "type": "object",
        "description": "Confirmation of a soft delete.",
        "required": [
          "slug",
          "deleted_at"
        ],
        "properties": {
          "slug": {
            "type": "string",
            "example": "quarterly-company-profile"
          },
          "deleted_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the workflow was soft-deleted.",
            "example": "2026-01-20T16:45:00Z"
          }
        }
      },
      "WorkflowError": {
        "type": "object",
        "description": "Workflow error response. `error` is a machine-readable code; `message` is human-readable text.",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Machine-readable error code.",
            "example": "invalid_output_formats"
          },
          "message": {
            "type": "string",
            "description": "Human-readable explanation.",
            "example": "output_formats may contain at most one JSON schema, which cannot be combined with markdown or pdf."
          }
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "The request was malformed or contained invalid parameters.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "example": {
                "summary": "Invalid parameters",
                "value": {
                  "success": false,
                  "error": "Invalid search_type. Must be 'all', 'web', 'proprietary', or 'news'"
                }
              }
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Missing or invalid API key. Send your key in the `X-API-Key` header.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "missing_or_invalid": {
                "summary": "Missing or invalid API key",
                "value": {
                  "error": "Unauthorized",
                  "message": "API key is missing or invalid"
                }
              },
              "invalid_key": {
                "summary": "Invalid API key (endpoint response)",
                "value": {
                  "success": false,
                  "error": "Invalid API key"
                }
              }
            }
          }
        }
      },
      "PaymentRequired": {
        "description": "The request can't be paid for. Nothing is charged.\n\n`code` tells you why:\n- `insufficient_credits` - the balance is used up. Top up, or wait for your plan's monthly allowance to renew.\n- `credit_limit_reached` - the organisation's optional monthly usage limit is reached. Raise the limit in the dashboard.\n- `spend_cap_reached` - this API key's budget cap is reached. Raise the key's cap or use another key.\n\nSearch, Contents and Answer return the body shown in the examples. `error` is a sentence you can relay that ends with the link that fixes it, and `recovery` repeats the links. Below the top self-serve plan, `insufficient_credits` also carries `upgrade_url`.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "insufficient_credits": {
                "summary": "Balance exhausted",
                "value": {
                  "success": false,
                  "error": "Your credit balance is used up. Nothing was charged. Top up to continue: https://platform.valyu.ai/user/account/billing?tab=credits Monthly plans give you cheaper credits and more data sources: https://platform.valyu.ai/user/account/billing?tab=plan",
                  "code": "insufficient_credits",
                  "recovery": {
                    "topup_url": "https://platform.valyu.ai/user/account/billing?tab=credits",
                    "topup_api": "POST https://api.valyu.ai/v1/account/balance/topup",
                    "upgrade_url": "https://platform.valyu.ai/user/account/billing?tab=plan"
                  },
                  "transaction_id": "tx_a1b2c3d4-e5f6-7890-abcd-ef1234567890"
                }
              },
              "credit_limit_reached": {
                "summary": "Monthly usage limit reached",
                "value": {
                  "success": false,
                  "error": "Your organisation's monthly credit limit is reached. Nothing was charged. Raise the limit to continue: https://platform.valyu.ai/user/account/billing?tab=credits",
                  "code": "credit_limit_reached",
                  "recovery": {
                    "increase_limit_url": "https://platform.valyu.ai/user/account/billing?tab=credits"
                  },
                  "transaction_id": "tx_a1b2c3d4-e5f6-7890-abcd-ef1234567890"
                }
              },
              "spend_cap_reached": {
                "summary": "API key budget cap reached",
                "value": {
                  "success": false,
                  "error": "This API key has reached its credit cap. Nothing was charged. Raise the key's cap or use an uncapped key: https://platform.valyu.ai/user/account/apikeys",
                  "code": "spend_cap_reached",
                  "recovery": {
                    "increase_cap_url": "https://platform.valyu.ai/user/account/apikeys"
                  },
                  "transaction_id": "tx_a1b2c3d4-e5f6-7890-abcd-ef1234567890"
                }
              }
            }
          }
        }
      },
      "Forbidden": {
        "description": "The API key is disabled, revoked or lacks permission for this operation. A request over the rate limit returns `429`, not `403`.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "forbidden": {
                "summary": "Key disabled or revoked",
                "value": {
                  "error": "Forbidden",
                  "message": "Access denied - API key is invalid, disabled, or revoked"
                }
              },
              "permission": {
                "summary": "Key lacks permission",
                "value": {
                  "success": false,
                  "error": "API key does not have inference permission"
                }
              }
            }
          }
        }
      },
      "RateLimited": {
        "description": "Over this endpoint's rate limit for your plan. Nothing is charged. Wait `retry_after` seconds (the `Retry-After` header), then retry with backoff. See [Rate limits](https://docs.valyu.ai/api-reference/overview#rate-limits).\n\n`message` is a sentence you can relay that names the limit and how to raise it. `error` and `code` are both `rate_limited`, and `recovery` repeats `retry_after`, `plan`, `limit` and `upgrade_url` (`contact_url` on the top plans), which also stay at the top level.",
        "headers": {
          "Retry-After": {
            "description": "Seconds to wait before retrying.",
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "rate_limited": {
                "summary": "Search rate limit reached",
                "value": {
                  "error": "rate_limited",
                  "code": "rate_limited",
                  "message": "Search rate limit reached: your Pay-as-you-go plan allows 5 requests per second. Retry after 2 seconds. Upgrade to Ridiculously Cheap for 10 requests per second: https://platform.valyu.ai/user/account/billing?tab=plan",
                  "retry_after": 2,
                  "plan": "Pay-as-you-go",
                  "limit": {
                    "endpoint": "search",
                    "requests_per_second": 5
                  },
                  "upgrade_url": "https://platform.valyu.ai/user/account/billing?tab=plan",
                  "recovery": {
                    "retry_after": 2,
                    "upgrade_url": "https://platform.valyu.ai/user/account/billing?tab=plan",
                    "plan": "Pay-as-you-go",
                    "limit": {
                      "endpoint": "search",
                      "requests_per_second": 5
                    }
                  }
                }
              }
            }
          }
        }
      },
      "NotFound": {
        "description": "The requested resource was not found.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "example": {
                "summary": "Resource not found",
                "value": {
                  "success": false,
                  "error": "Task not found"
                }
              }
            }
          }
        }
      },
      "InternalServerError": {
        "description": "An unexpected error occurred on the server.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "example": {
                "summary": "Internal error",
                "value": {
                  "success": false,
                  "error": "Internal server error. Please try again later."
                }
              }
            }
          }
        }
      },
      "WorkflowBadRequest": {
        "description": "The workflow request was invalid. The `error` field carries a machine-readable code and `message` a human-readable explanation.\n\nCommon codes:\n- `changelog_required` - a changelog is required when publishing a new version\n- `unreferenced_template_vars` - a declared variable is not used in the prompt template, or the template references an unknown variable\n- `invalid_output_formats` - `output_formats` contained more than one JSON schema, mixed a schema with `markdown`/`pdf`, or used `toon` without a schema\n- `field_too_long` - a text field exceeds its limit (64 KB)\n- `too_many_variables` - more than 50 variables\n- `too_many_deliverables` - more than 20 deliverables\n- `workflow_and_freeform_mutually_exclusive` - workflow and freeform fields were both supplied (on the DeepResearch create endpoint)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/WorkflowError"
            },
            "examples": {
              "changelog_required": {
                "summary": "Changelog required",
                "value": {
                  "error": "changelog_required",
                  "message": "A changelog is required when publishing a new version."
                }
              },
              "unreferenced_template_vars": {
                "summary": "Unreferenced template variable",
                "value": {
                  "error": "unreferenced_template_vars",
                  "message": "A declared variable is not used in the prompt template, or the template references an unknown variable."
                }
              },
              "invalid_output_formats": {
                "summary": "Invalid output_formats",
                "value": {
                  "error": "invalid_output_formats",
                  "message": "output_formats may contain at most one JSON schema, which cannot be combined with markdown or pdf; toon requires a schema."
                }
              }
            }
          }
        }
      },
      "WorkflowForbidden": {
        "description": "The operation is not permitted on this workflow.\n\nCommon codes:\n- `cannot_edit_valyu_workflow` - curated Valyu workflows are read-only\n- `cannot_delete_valyu_workflow` - curated Valyu workflows cannot be deleted",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/WorkflowError"
            },
            "examples": {
              "cannot_edit_valyu_workflow": {
                "summary": "Cannot edit a curated workflow",
                "value": {
                  "error": "cannot_edit_valyu_workflow",
                  "message": "Valyu-curated workflows are read-only."
                }
              }
            }
          }
        }
      },
      "WorkflowNotFound": {
        "description": "The workflow or version was not found.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/WorkflowError"
            },
            "examples": {
              "workflow_not_found": {
                "summary": "Workflow not found",
                "value": {
                  "error": "workflow_not_found",
                  "message": "No workflow matches that slug."
                }
              }
            }
          }
        }
      },
      "WorkflowConflict": {
        "description": "The workflow could not be created due to a conflict.\n\nCommon codes:\n- `workflow_quota_exceeded` - your organization has reached its workflow quota (default 100)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/WorkflowError"
            },
            "examples": {
              "workflow_quota_exceeded": {
                "summary": "Workflow quota exceeded",
                "value": {
                  "error": "workflow_quota_exceeded",
                  "message": "Your organization has reached its workflow quota."
                }
              }
            }
          }
        }
      },
      "ServiceUnavailable": {
        "description": "Billing could not be checked, so no task was created and nothing was charged. Retry with exponential backoff.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "billing_unavailable": {
                "summary": "Billing temporarily unavailable",
                "value": {
                  "error": "Billing temporarily unavailable"
                }
              }
            }
          }
        }
      },
      "DeepResearchPaymentRequired": {
        "description": "The task can't be paid for, so it was not created. Nothing is charged.\n\nWhen you create a task, its mode's base price is held against your balance until the task is charged. `available` in the message is your balance minus amounts already held for your other queued and running tasks. DeepResearch error bodies have `error` (and `code` for budget caps) but no `success` field.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "insufficient": {
                "summary": "Balance does not cover the task price",
                "value": {
                  "error": "Insufficient credits."
                }
              },
              "no_balance": {
                "summary": "Balance exhausted",
                "value": {
                  "error": "Insufficient credits. Please top up your account."
                }
              },
              "limit": {
                "summary": "Monthly usage limit reached",
                "value": {
                  "error": "Monthly credit limit exceeded. Please increase your limits."
                }
              },
              "spend_cap": {
                "summary": "API key budget cap reached",
                "value": {
                  "error": "API key budget cap reached. Raise the key's credit cap or use an uncapped key.",
                  "code": "spend_cap_reached"
                }
              }
            }
          }
        }
      }
    }
  }
}
