---
title: "nua.get()"
description: "Reference for nua.get(), which produces a single typed value from a prompt and an optional input."
canonical: "https://nuabase.com/docs/api/get/"
---

> Documentation index: https://nuabase.com/llms.txt

`get()` produces a single value. Use it to transform, classify, extract from, or generate from a single input.

## Signatures

```typescript
// Prompt only: a plain string
nua.get(prompt: string): Promise<CastResult<string>>

// With options: a value matching the schema
nua.get<S extends z.ZodTypeAny>(prompt: string, options: GetOptions<S>): Promise<CastResult<z.infer<S>>>
```

## Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `prompt` | `string` | Yes | Instructions for the LLM. Keep it constant across calls; put what varies in `input`. |
| `options.input` | `unknown` | No | Data to process. Any JSON-serializable value. |
| `options.output.name` | `string` | Yes | A name for the generated value, such as `'address'`. The model sees it, so make it descriptive. |
| `options.output.schema` | Zod schema | Yes | The shape of the value: an object, array, or primitive. The answer is parsed with it, so defaults, transforms, and refinements apply. |
| `options.model` | `ModelInput` | No | Overrides the client's default model for this call. |

## Examples

### Plain string

```typescript
const result = await nua.get('What is the chemical formula for water?');

if (result.success) {
  console.log(result.data); // "H2O"
}
```

### Data extraction

```typescript
const AddressSchema = z.object({
  street: z.string(),
  city: z.string(),
  state: z.string(),
  zipCode: z.string(),
});

const result = await nua.get('Extract the address from this text', {
  input: 'Please ship to 123 Main St, Springfield, IL 62701',
  output: { name: 'address', schema: AddressSchema },
});

if (result.success) {
  console.log(result.data.city); // "Springfield"
}
```

### Classification

```typescript
const TicketSchema = z.object({
  category: z.enum(['bug', 'feature', 'question', 'other']),
  priority: z.enum(['low', 'medium', 'high']),
  summary: z.string(),
});

const result = await nua.get('Classify this support ticket', {
  input: 'The app crashes when I click the submit button. This is blocking our team.',
  output: { name: 'classification', schema: TicketSchema },
});

if (result.success) {
  console.log(result.data.category); // "bug"
  console.log(result.data.priority); // "high"
}
```

### Generating from structured input

```typescript
const EmailSchema = z.object({
  subject: z.string(),
  body: z.string(),
  tone: z.enum(['formal', 'casual', 'friendly']),
});

const result = await nua.get('Draft a follow-up email to the attendee', {
  input: {
    meeting: 'Q4 Planning Session',
    attendee: 'John',
    keyPoints: ['Budget approved', 'Timeline set for December'],
  },
  output: { name: 'email', schema: EmailSchema },
});
```

### Primitive outputs

The schema doesn't have to be an object:

```typescript
const hasQuestion = await nua.get('Does this message contain a question?', {
  input: 'I was wondering if you could help me with something.',
  output: { name: 'hasQuestion', schema: z.boolean() },
});
// hasQuestion.data: boolean

const revenue = await nua.get('Extract Q3 revenue in US dollars', {
  input: 'Q3 revenue hit $2.5M with 15% growth.',
  output: { name: 'revenueUsd', schema: z.number() },
});
// revenue.data: number (2500000)
```

### Choosing a model per call

```typescript
const result = await nua.get('Extract the address from this text', {
  input: text,
  output: { name: 'address', schema: AddressSchema },
  model: { alias: 'sonnet' },
});
```

## Error handling

```typescript
const result = await nua.get('Classify this support ticket', { input, output });

if (!result.success) {
  showError(result.reason); // why it failed, in the agent's or provider's words
  logger.warn(result.error); // a one-line summary: attempts made and the last failure
  return;
}

processData(result.data);
```

See [API Overview](/docs/api.md#errors) for which failures are returned and which throw.
