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

# @cascadeflow/core

> Entry point for the TypeScript cascade, harness, routing, tool, quality, and telemetry APIs.

`@cascadeflow/core` contains two complementary runtime APIs:

* `CascadeAgent` performs speculative model cascading and quality validation.
* The harness observes or enforces policy around OpenAI and Anthropic SDK calls.

## Install

```bash theme={null}
npm install @cascadeflow/core
```

Node.js 18 or newer is required.

## Cascade API

```typescript theme={null}
import { CascadeAgent } from '@cascadeflow/core';

const agent = new CascadeAgent({
  models: [
    { name: 'gpt-4o-mini', provider: 'openai', cost: 0.00015 },
    { name: 'gpt-4o', provider: 'openai', cost: 0.0025 },
  ],
});

const result = await agent.run('Summarize this document');
console.log(result.content);
console.log(result.modelUsed, result.totalCost, result.savingsPercentage);
```

See [CascadeAgent](/api-reference/typescript/cascade-agent), [Configuration](/api-reference/typescript/configuration), and [CascadeResult](/api-reference/typescript/result).

## Harness API

```typescript theme={null}
import { init, run } from '@cascadeflow/core';

init({ mode: 'observe' });

await run({ budget: 0.50 }, async (session) => {
  await existingAgentWork();
  console.log(session.summary());
  console.log(session.trace());
});
```

See [Harness](/api-reference/typescript/harness).

## Main Export Groups

| Area | Main exports |
| - | - |
| Cascade | `CascadeAgent`, `AgentConfig`, `RunOptions`, `CascadeResult` |
| Harness | `init`, `run`, `harnessAgent`, `HarnessRunContext` |
| Streaming | `StreamEventType`, `collectStream`, `collectResult` |
| Tools | `ToolConfig`, `ToolExecutor`, `ToolCall`, `ToolResult` |
| Quality | `QualityValidator`, `SemanticQualityChecker`, `ComplexityDetector` |
| Routing | `PreRouter`, `ToolRouter`, `TierRouter`, `DomainRouter`, `RuleEngine` |
| Providers | OpenAI, Anthropic, Groq, Together, Ollama, Hugging Face, vLLM, OpenRouter, and Vercel AI adapters |
| Operations | `BatchProcessor`, `RetryManager`, `ResponseCache`, `RateLimiter` |
| Telemetry | `CallbackManager`, `MetricsCollector`, `CostCalculator`, `OpenTelemetryExporter` |

## Next Steps

<CardGroup cols={2}>
  <Card title="Build a cascade" icon="layer-group" href="/api-reference/typescript/cascade-agent">
    Configure models, quality checks, routing, streaming, and batch execution.
  </Card>

  <Card title="Add runtime policy" icon="shield" href="/api-reference/typescript/harness">
    Observe or enforce budgets, tool caps, energy, latency, and compliance.
  </Card>

  <Card title="Execute tools" icon="wrench" href="/api-reference/typescript/tools">
    Define tools and run automatic multi-step tool loops.
  </Card>

  <Card title="Check feature parity" icon="table-columns" href="/api-reference/typescript/feature-parity">
    Compare the current Python and TypeScript surfaces.
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.