SDK API Reference
Comprehensive API reference for the Agentsmith SDK.
This page provides a detailed reference for all the classes, methods, and options available in the Agentsmith SDK.
AgentsmithClient
The main client for interacting with the Agentsmith API.
Constructor
new AgentsmithClient<T>(apiKey, projectId, options)
Parameters:
apiKey: string
(required)projectId: string
(required)options: AgentsmithClientOptions
(optional)
AgentsmithClientOptions
Prop | Type | Default |
---|---|---|
agentsmithApiRoot? | string | https://agentsmith.dev |
supabaseUrl? | string | - |
supabaseAnonKey? | string | - |
agentsmithDirectory? | string | ./agentsmith |
queueOptions? | PQueueOptions | - |
fetchStrategy? | FetchStrategy | remote-fallback |
logger? | Logger | - |
logLevel? | LogLevel | warn |
completionLogsDirectory? | string | null | - |
completionLogDirTransformer? | (options: object) => string | - |
Methods
getPrompt(arg)
Fetches a prompt from Agentsmith.
arg: PromptIdentifier<Agency>
(required): The identifier for the prompt, e.g.,'my-prompt'
or'my-prompt@1.2.3'
.
Returns: Promise<Prompt<Agency, PromptArg>>
shutdown()
Gracefully shuts down the client, ensuring all background operations complete. This is crucial for allowing scripts and serverless functions to exit cleanly.
Prompt
Represents a single, versioned prompt fetched from Agentsmith. It is not constructed directly, but rather returned from agentsmithClient.getPrompt
.
Methods
compile(variables, options)
Compiles the prompt with the given variables.
CompileOptions
Prop | Type | Default |
---|---|---|
globals? | Partial<Agency['globals']> | - |
CompileResult
Prop | Type | Default |
---|---|---|
finalVariables? | any | - |
compiledPrompt? | string | - |
execute(variables, options)
Executes the prompt with the given variables. The execute
method returns an object with different fields depending on whether streaming is enabled.
ExecuteOptions
Prop | Type | Default |
---|---|---|
config? | CompletionConfig | - |
globals? | Partial<Agency['globals']> | - |
ExecuteNonStreamingResult
Prop | Type | Default |
---|---|---|
content? | string | null | - |
reasoning? | string | null | - |
toolCalls? | ToolCall[] | null | - |
completion? | OpenrouterNonStreamingResponse | - |
response? | Response | - |
logUuid? | string | - |
compiledPrompt? | string | - |
finalVariables? | any | - |
ExecuteStreamingResult
Prop | Type | Default |
---|---|---|
tokens? | AsyncGenerator<string | undefined, void, unknown> | - |
reasoningTokens? | AsyncGenerator<string | undefined, void, unknown> | - |
toolCalls? | AsyncGenerator<ToolCall, void, unknown> | - |
stream? | ReadableStream<Uint8Array> | - |
completion? | Promise<OpenrouterNonStreamingResponse> | - |
response? | Response | - |
logUuid? | string | - |
compiledPrompt? | string | - |
finalVariables? | any | - |
CompletionLogDirTransformerOptions
Prop | Type | Default |
---|---|---|
logUuid? | string | - |
prompt? | { name: string; slug: string; uuid: string; } | - |
promptVersion? | { uuid: string; version: string; config: any; content: string; } | - |
variables? | Record<string, any> | - |
rawInput? | any | - |
rawOutput? | any | - |