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

# Agentic Functions

### `agentic`

A function used to create an agentic function.

```typescript wrap theme={null}
async function agentic<T>(
    userPrompt: string,
    scope?: object,
    config?: {
      model?: ModelStrings,
      premise?: string,
      system?: string | Template,
      maxTokens?: number | MaxTokens,
      onUsage?: (usage: Usage) => void;
      listener?: (iid: string, chunk: Chunk) => void,
      listenerIncludeUsage?: boolean;
      reasoningEffort?: ReasoningEffort;
      cacheTTL?: '5m' | '1h';
    },
): Promise<T>;
```

**Parameters**

<ParamField body="prompt" type="string">
  The task description that guides the underlying agent's execution. This describes what the function should do.
</ParamField>

<ParamField body="scope" type="object">
  Optional. An object containing runtime resources that are available during execution.
  Resources in scope may be functions, methods, objects, types or any other value.
</ParamField>

<ParamField body="config" type="object">
  Optional configuration object for the agentic function execution.
</ParamField>

<ParamField body="config.premise" type="string">
  An optional premise for the agentic function. This will be attached to the system prompt of all invocations of this agentic function.

  <Warning>
    This argument cannot be provided along with the `config.system` argument.
  </Warning>
</ParamField>

<ParamField body="config.system" type="string | Template">
  An optional system prompt for the agentic function. This will be the system prompt of all invocations of this agentic function.
  Either

  * a `string`, or
  * or an instance of [`Template`](/references/ts/templating#template).

  <Warning>
    This argument cannot be provided along with the `config.premise` argument.
  </Warning>
</ParamField>

<ParamField body="config.model" type="string">
  The model which backs your agent.
  Any OpenRouter model slug.

  <Note>
    The default model is `openai/gpt-4.1`.
  </Note>
</ParamField>

<ParamField body="config.maxTokens" type="number | MaxTokens">
  Either

  * the maximum number of output tokens generated over all rounds of inference in a single invocation, or
  * an instance of `MaxTokens` for more fine-grained control.

  See [`MaxTokens`](/references/ts/usage#maxtokens) for information on default values.
</ParamField>

<ParamField body="config.onUsage" type="(usage: Usage) => void">
  A callback to obtain the token usage of an agentic function for the last invocation.
</ParamField>

<ParamField body="config.listener" type="(iid: string, chunk: Chunk) => void">
  A callback for streaming model generation.
  Each streamed *text chunk* for each agentic function call, determined by a unique *invocation ID*, will route to this callback.
</ParamField>

<ParamField body="config.listenerIncludeUsage" type="boolean">
  Whether to include usage-reporting chunks (`chunk.type === 'usage'`) in the listener stream. Defaults to `false`.
</ParamField>

<ParamField body="config.reasoningEffort" type="ReasoningEffort">
  Constrains the thinking budget on reasoning models which support it (e.g. GPT 5.2, Sonnet 4.5, Gemini 3).

  One of: `'none'`, `'minimal'`, `'low'`, `'medium'`, `'high'`, `'xhigh'`.

  If omitted, uses the model's default reasoning effort.
</ParamField>

<ParamField body="config.cacheTTL" type="'5m' | '1h'">
  Controls how long Anthropic prompt caching entries persist. Only used for Anthropic models.

  `'5m'` is the default cache duration. `'1h'` costs more but caches longer.
</ParamField>

<ResponseField name="Returns" type="Promise<T>">
  Returns a promise that resolves to the result of specified or inferred return type `T`.
</ResponseField>
