> ## Documentation Index
> Fetch the complete documentation index at: https://docs.case.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# AI Answer

> Get AI-generated answers with citations

We search the web, synthesize the results, and cite our sources.

```bash title="Endpoint" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
POST /search/v1/answer
```

<CodeGroup>
  ```bash title="cURL" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  curl -X POST https://api.case.dev/search/v1/answer \
    -H "Authorization: Bearer sk_case_YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "query": "What is the statute of limitations for medical malpractice in California?"
    }'
  ```

  ```bash title="CLI" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  casedev search:v1 answer \
    --query "What is the statute of limitations?"
  ```

  ```typescript title="Typescript" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  import Casedev from 'casedev';

  const client = new Casedev({ apiKey: 'sk_case_YOUR_API_KEY' });

  const result = await client.search.v1.answer({
    query: 'What is the statute of limitations for medical malpractice in California?'
  });

  console.log(result.answer);
  // "In California, the statute of limitations for medical malpractice
  //  is generally 3 years from the date of injury or 1 year from when
  //  the patient discovered the injury [1]. Exceptions exist for
  //  foreign objects [2] and minors [3]."

  for (const citation of result.citations) {
    console.log(`[${citation.id}] ${citation.title}: ${citation.url}`);
  }
  ```

  ```python title="Python" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  import casedev

  client = casedev.Casedev(api_key='sk_case_YOUR_API_KEY')

  result = client.search.v1.answer(
      query='What is the statute of limitations for medical malpractice in California?'
  )

  print(result.answer)

  for citation in result.citations:
      print(f'[{citation.id}] {citation.title}: {citation.url}')
  ```

  ```go title="Go" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  result, _ := client.Search.V1.Answer(ctx, casedev.SearchV1AnswerParams{
  	Query: casedev.F("What is the statute of limitations?"),
  })
  fmt.Println(result.Answer)
  for _, c := range result.Citations {
  	fmt.Printf("[%s] %s: %s\n", c.ID, c.Title, c.URL)
  }
  ```
</CodeGroup>

```json title="Response" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
{
  "answer": "In California, the statute of limitations for medical malpractice is generally 3 years from the date of injury or 1 year from when the patient discovered or should have discovered the injury, whichever comes first [1]. However, there are exceptions for cases involving foreign objects left in the body [2] and for minors [3].",
  "citations": [
    {
      "id": "1",
      "url": "https://law.cornell.edu/california/medical-malpractice",
      "title": "California Medical Malpractice Laws",
      "text": "California Code of Civil Procedure Section 340.5..."
    },
    {
      "id": "2",
      "url": "https://findlaw.com/healthcare/foreign-object-exception",
      "title": "Foreign Object Exception",
      "text": "When a foreign object is left in the body..."
    }
  ]
}
```

## Parameters

| Parameter        | Type    | Default      | Description                           |
| ---------------- | ------- | ------------ | ------------------------------------- |
| `query`          | string  | **Required** | Question to answer                    |
| `numResults`     | number  | 10           | Number of sources to search           |
| `includeDomains` | array   | —            | Only search these domains             |
| `excludeDomains` | array   | —            | Exclude these domains                 |
| `useCustomLLM`   | boolean | `false`      | Use Case.dev LLM for answer           |
| `model`          | string  | `gpt-4o`     | LLM model (when `useCustomLLM: true`) |
| `stream`         | boolean | `false`      | Stream the response                   |

## Examples

### Basic question

<CodeGroup>
  ```bash title="CLI" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  casedev search:v1 answer \
    --query "What are the requirements for a valid non-compete agreement in Texas?"
  ```

  ```typescript title="Typescript" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  const result = await client.search.v1.answer({
    query: 'What are the requirements for a valid non-compete agreement in Texas?'
  });
  ```

  ```python title="Python" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  result = client.search.v1.answer(
      query='What are the requirements for a valid non-compete agreement in Texas?'
  )
  ```

  ```go title="Go" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  result, _ := client.Search.V1.Answer(ctx, casedev.SearchV1AnswerParams{
      Query: casedev.F("What are the requirements for a valid non-compete agreement in Texas?"),
  })
  ```
</CodeGroup>

### Authoritative sources only

<CodeGroup>
  ```bash title="CLI" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  casedev search:v1 answer \
    --query "What is the current federal minimum wage?" \
    --include-domain dol.gov \
    --include-domain law.cornell.edu \
    --include-domain congress.gov \
    --num-results 5
  ```

  ```typescript title="Typescript" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  const result = await client.search.v1.answer({
    query: 'What is the current federal minimum wage?',
    includeDomains: ['dol.gov', 'law.cornell.edu', 'congress.gov'],
    numResults: 5
  });
  ```

  ```python title="Python" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  result = client.search.v1.answer(
      query='What is the current federal minimum wage?',
      include_domains=['dol.gov', 'law.cornell.edu', 'congress.gov'],
      num_results=5
  )
  ```

  ```go title="Go" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  result, _ := client.Search.V1.Answer(ctx, casedev.SearchV1AnswerParams{
      Query:          casedev.F("What is the current federal minimum wage?"),
      IncludeDomains: casedev.F([]string{"dol.gov", "law.cornell.edu", "congress.gov"}),
      NumResults:     casedev.F(int64(5)),
  })
  ```
</CodeGroup>

### With custom LLM

<CodeGroup>
  ```bash title="CLI" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  casedev search:v1 answer \
    --query "Explain the differences between Chapter 7 and Chapter 11 bankruptcy" \
    --use-custom-llm \
    --model "anthropic/claude-sonnet-4.5"
  ```

  ```typescript title="Typescript" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  const result = await client.search.v1.answer({
    query: 'Explain the differences between Chapter 7 and Chapter 11 bankruptcy',
    useCustomLLM: true,
    model: 'anthropic/claude-sonnet-4.5'
  });
  ```

  ```python title="Python" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  result = client.search.v1.answer(
      query='Explain the differences between Chapter 7 and Chapter 11 bankruptcy',
      use_custom_llm=True,
      model='anthropic/claude-sonnet-4.5'
  )
  ```

  ```go title="Go" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  result, _ := client.Search.V1.Answer(ctx, casedev.SearchV1AnswerParams{
      Query:        casedev.F("Explain the differences between Chapter 7 and Chapter 11 bankruptcy"),
      UseCustomLlm: casedev.F(true),
      Model:        casedev.F("anthropic/claude-sonnet-4.5"),
  })
  ```
</CodeGroup>

<Warning>
  **Web data only.** For comprehensive legal research, use Lexis, Westlaw, or OpenLaws.
</Warning>
