---
title: "C#/.NET API Reference Code Agent SDK"
source: https://docs.autohand.ai/agent-sdk/csharp-api
---

# C#/.NET API Reference

Reference surface for the C#/.NET SDK. These APIs wrap the Autohand CLI JSON-RPC runtime while keeping host-language lifecycle and event handling idiomatic.

**Source:** [autohandai/code-agent-sdk-csharp/docs/API\_REFERENCE.md](https://github.com/autohandai/code-agent-sdk-csharp/blob/main/docs/API_REFERENCE.md).

## Install

## \`AutohandOptions\`

Configuration sets the working directory, CLI binary path, debug output, request timeout, model override, skills, system prompt additions, and execution-mode flags.

## \`AutohandSdk\`

Use the low-level wrapper when you need direct JSON-RPC control.

-   StartAsync() / StopAsync()
-   RequestAsync(method, parameters)
-   PromptAsync(message, options)
-   StreamPromptAsync(message, options)
-   InterruptAsync()
-   SetPlanModeAsync(enabled)
-   SetPermissionModeAsync(mode)
-   SetModelAsync(model)
-   GetStateAsync()
-   GetMessagesAsync()
-   PermissionResponseAsync(requestId, decision)

## \`Agent\`

The high-level agent API is the best fit for product code that sends prompts, streams events, and waits for final results.

-   Agent.CreateAsync(options)
-   Agent.FromSdk(sdk)
-   Send(prompt, options)
-   RunAsync(prompt, options)
-   RunJsonAsync<T>(prompt, jsonOptions, promptOptions)
-   AllowPermissionAsync(requestId)
-   DenyPermissionAsync(requestId)
-   SuggestPermissionAlternativeAsync(requestId, alternative)
-   SetPlanModeAsync(enabled)

## Run

-   StreamAsync(): stream events
-   WaitAsync(): wait until the run finishes and collect text/events
-   JsonAsync<T>(): parse final output as JSON
-   AbortAsync(): interrupt the current run

## SDK events

All CLI-backed SDKs expose the same runtime event names, with language-specific wrappers or helper methods around the raw JSON payload.

-   `agent_start`
-   `turn_start`
-   `message_update`
-   `message_end`
-   `tool_start`
-   `tool_update`
-   `tool_end`
-   `permission_request`
-   `error`

## Structured JSON

Use the JSON helpers when the host application needs typed output from the final assistant response.