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

# TypeScript SDK

> Add Octen to your TypeScript or JavaScript project.

For AI agents: [docs.octen.ai/integrations/typescript-sdk.md](https://docs.octen.ai/integrations/typescript-sdk.md)

> [card] [Get API Key](https://octen.ai/platform/api-keys)
>
> Create a key from the API Platform.

> [card] [npm](https://www.npmjs.com/package/@octen.ai/sdk)
>
> The `@octen.ai/sdk` package.

## Install

Requires Node.js 20+.

```bash npm theme={null}
npm install @octen.ai/sdk
```

## Quick Start

```typescript theme={null}
import Octen from "@octen.ai/sdk";

const client = new Octen({ apiKey: "your-api-key" }); // or set OCTEN_API_KEY env var

const response = await client.search.search({
  query: "latest advances in solid-state batteries",
  count: 5,
});
for (const r of response.data?.results ?? []) {
  console.log(r.title, r.url);
}
```

Responses are the parsed JSON body, with the same field names as the [API reference](https://docs.octen.ai/api-reference/search.md). Most response fields are typed as optional, so read them with `?.`.

The TypeScript SDK covers the APIs on this page. For other APIs, such as [Embedding](https://docs.octen.ai/api-reference/embedding.md), send HTTP requests as shown in the API reference.

## Broad Search

Decompose a query into sub-queries, search them concurrently, and get results grouped per sub-query. Best for comparisons, surveys, and multi-angle questions.

```typescript theme={null}
const response = await client.search.broadSearch({
  query: "compare cloud GPU pricing across providers",
  max_queries: 5, // up to N sub-queries (1-30, default 5)
  search_options: { result_type: "dynamic" }, // only relevant results per sub-query (default "standard")
});
// response.data.queries -> sub-queries; response.data.search_results -> grouped results
```

## Web Search

Search the live web and get ranked results with model-ready highlights and optional full content. Best for search bars, answer engines, and news lookup.

```typescript theme={null}
const results = await client.search.search({
  query: "blog post about artificial intelligence",
  count: 10,
  time_range: "week",
  include_domains: ["techcrunch.com", "wired.com"],
  result_type: "dynamic", // only relevant results, up to count (default "standard")
});
```

## Web Search Premier

Search the live web with deeper retrieval and reranking, so the page that holds the answer ranks higher. Takes the same parameters as Web Search and returns the same response. Best for agent questions, specific facts, and named pages.

```typescript theme={null}
const response = await client.search.searchPremier({
  query: "latest guidance on EU AI Act compliance",
  result_type: "dynamic", // only relevant results, up to count (default "standard")
  count: 10,
});
// response.data.results -> ranked results, with the same fields as Web Search
```

## News Search

Search live news and get ranked articles, with related coverage grouped into storylines. Best for breaking news, media monitoring, and story tracking.

```typescript theme={null}
const response = await client.search.newsSearch({
  query: "EU AI Act enforcement",
  time_range: "week",
  count: 10,
});
// response.data.subjects -> storylines; response.data.results -> ranked articles
```

## Business Search

Get the companies and people behind a query as entity cards, alongside ranked sources. Best for company due diligence, people lookup, and competitor comparison.

```typescript theme={null}
const response = await client.search.businessSearch({
  query: "compare Stripe and Adyen payment processing",
  entities: { count: 2, max_news: 5 },
});
// response.data.entities -> entity cards; response.data.results -> ranked sources
```

## Place Search

Find places around a point or in a named area as cards with address, coordinates, phone, opening hours, and rating. Best for nearby recommendations, local lookup, and opening hours.

```typescript theme={null}
const response = await client.placeSearch.search({
  query: "coffee shops",
  latitude: 35.6812,
  longitude: 139.7671,
  radius: 1000, // meters (1-50000), needs both coordinates
  places: { count: 5 },
});
// response.data.places -> place cards, each with a distance
```

## Pulse Search

Predict the URL a query points to. Best for docs, help pages, and official sites.

```typescript theme={null}
const response = await client.search.pulseSearch({ query: "github docs", count: 5 });
// response.data.results -> titles and URLs; in the default lite mode, URLs have no scheme
```

## Image Search

Search images by a text query or a reference image. Best for image lookup and visual references.

```typescript theme={null}
const response = await client.imageSearch.search({
  inputs: [{ type: "text", data: "golden retriever puppy" }], // one input: text, or an image by url or base64 data
  count: 5,
});
```

## Design Search

Search real web pages, app screens, and slides, and get each as an image with its design values, plus web results on the same query. Best for landing pages, app screens, and slide decks.

```typescript theme={null}
const response = await client.designSearch.search({
  query: "pricing page with three tiers",
  images: { count: 5 },
});
// response.data.images -> design images with their design values; response.data.results -> web results
```

## Extract

Fetch 1-20 URLs in one call and get clean markdown or text. Best for reading pages, cleaning articles, and knowledge ingestion.

```typescript theme={null}
const response = await client.extract.extract({
  urls: ["https://docs.octen.ai/api-reference/search", "https://octen.ai"],
  format: "markdown",
});
// response.data.results -> one result per URL: full_content on success, error_message if status is "failed"
```

## Configuration

```typescript theme={null}
import Octen from "@octen.ai/sdk";

const client = new Octen({
  apiKey: "your-api-key",          // default: the OCTEN_API_KEY env var
  baseURL: "https://api.octen.ai", // default
  timeout: 60_000,                 // milliseconds, for every endpoint; if unset, 30000 (120000 for Broad Search)
  maxRetries: 3,                   // default 3
});
```

## Error Handling

```typescript theme={null}
import {
  OctenAuthenticationError,
  OctenRateLimitError,
  OctenTimeoutError,
  OctenConnectionError,
  OctenValidationError,
  OctenAPIError,
} from "@octen.ai/sdk";

try {
  const results = await client.search.search({ query: "query" });
} catch (err) {
  if (err instanceof OctenValidationError) {
    console.log(`Invalid request, not sent: ${err.message}`);
  } else if (err instanceof OctenAuthenticationError) {
    console.log("Invalid API key");
  } else if (err instanceof OctenRateLimitError) {
    console.log(`Rate limited, retry after ${err.retryAfter}s`);
  } else if (err instanceof OctenTimeoutError) {
    console.log("Request timed out");
  } else if (err instanceof OctenConnectionError) {
    console.log("Network connection failed");
  } else if (err instanceof OctenAPIError) {
    console.log(`API error: ${err.status} - ${err.message} (request ID: ${err.requestId})`);
  } else {
    throw err;
  }
}
```

Requests that fail with HTTP 408, 429, 500, 502, 503, or 504 are automatically retried with exponential backoff, up to `maxRetries` times. Connection errors before the request is sent are also retried. Timeouts are not retried.

Include `requestId` when you contact support.

***

Last modified on November 24, 2026


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