---
title: Example
seo:
  title: Example — TypeScript SDK
  description: >-
    A single evaluation example with flexible key-value properties. (TypeScript
    SDK)
description: A single evaluation example with flexible key-value properties.
---

Use `Example.create()` to construct an example with arbitrary fields
such as `input`, `actualOutput`, `expectedOutput`, etc.

```typescript
const example = Example.create({
  input: "What is the capital of France?",
  actual_output: "Paris is the capital of France.",
  expected_output: "Paris",
});

example.get("input"); // "What is the capital of France?"
```

## Attributes

| Prop | Type | Default | Description |
| - | - | - | - |
| `exampleId?` | `string` | - | |
| `createdAt?` | `string` | - | |
| `name?` | `string \| null` | - | |

***

<Badge>
  Static Method
</Badge>

## create()

Create an example with the given properties.

Any key-value pairs passed in `props` become accessible via `.get()`.
Common keys: `input`, `actual_output`, `expected_output`, `retrieval_context`.

```typescript
function create(props: Record<string, unknown> = {}): Example
```

### Parameters

| Prop | Type | Default | Description |
| - | - | - | - |
| `props?` | `Record<string, unknown>` | `{}` | |

### Returns

`Example`

***

<Badge>
  Static Method
</Badge>

## from()

Reconstruct an Example from an API response dict.

Separates the fixed metadata fields (`example_id`, `created_at`, `name`)
from user-defined properties.

```typescript
function from(data: ExampleDict): Example
```

### Parameters

| Prop | Type | Default | Description |
| - | - | - | - |
| `data` | `ExampleDict` | - | |

### Returns

`Example`

***

## get()

Get a property by key.

```typescript
function get(key: string): unknown
```

### Parameters

| Prop | Type | Default | Description |
| - | - | - | - |
| `key` | `string` | - | |

### Returns

`unknown`

***

## has()

Check if a property key exists.

```typescript
function has(key: string): boolean
```

### Parameters

| Prop | Type | Default | Description |
| - | - | - | - |
| `key` | `string` | - | |

### Returns

`boolean`

***

## toJSON()

Serialize to the API wire format.

```typescript
function toJSON(): ExampleDict
```

### Returns

`ExampleDict`
