@@ -127,24 +127,24 @@ You can request structured JSON output from the model by specifying an `outputFo
127127const result = await client .session .prompt ({
128128 path: { id: sessionId },
129129 body: {
130- parts: [{ type: ' text' , text: ' Research Anthropic and provide company info' }],
130+ parts: [{ type: " text" , text: " Research Anthropic and provide company info" }],
131131 outputFormat: {
132- type: ' json_schema' ,
132+ type: " json_schema" ,
133133 schema: {
134- type: ' object' ,
134+ type: " object" ,
135135 properties: {
136- company: { type: ' string' , description: ' Company name' },
137- founded: { type: ' number' , description: ' Year founded' },
136+ company: { type: " string" , description: " Company name" },
137+ founded: { type: " number" , description: " Year founded" },
138138 products: {
139- type: ' array' ,
140- items: { type: ' string' },
141- description: ' Main products'
142- }
139+ type: " array" ,
140+ items: { type: " string" },
141+ description: " Main products" ,
142+ },
143143 },
144- required: [' company' , ' founded' ]
145- }
146- }
147- }
144+ required: [" company" , " founded" ],
145+ },
146+ },
147+ },
148148})
149149
150150// Access the structured output
@@ -154,29 +154,29 @@ console.log(result.data.info.structured_output)
154154
155155### Output Format Types
156156
157- | Type | Description |
158- | ------| -------------|
159- | ` text ` | Default. Standard text response (no structured output) |
160- | ` json_schema ` | Returns validated JSON matching the provided schema |
157+ | Type | Description |
158+ | ------------- | ------------------------------------------------------ |
159+ | ` text ` | Default. Standard text response (no structured output) |
160+ | ` json_schema ` | Returns validated JSON matching the provided schema |
161161
162162### JSON Schema Format
163163
164164When using ` type: 'json_schema' ` , provide:
165165
166- | Field | Type | Description |
167- | -------| ------| -------------|
168- | ` type ` | ` 'json_schema' ` | Required. Specifies JSON schema mode |
169- | ` schema ` | ` object ` | Required. JSON Schema object defining the output structure |
170- | ` retryCount ` | ` number ` | Optional. Number of validation retries (default: 2) |
166+ | Field | Type | Description |
167+ | ------------ | --------------- | ---------------------------------------------------------- |
168+ | ` type ` | ` 'json_schema' ` | Required. Specifies JSON schema mode |
169+ | ` schema ` | ` object ` | Required. JSON Schema object defining the output structure |
170+ | ` retryCount ` | ` number ` | Optional. Number of validation retries (default: 2) |
171171
172172### Error Handling
173173
174174If the model fails to produce valid structured output after all retries, the response will include a ` StructuredOutputError ` :
175175
176176``` typescript
177- if (result .data .info .error ?.name === ' StructuredOutputError' ) {
178- console .error (' Failed to produce structured output:' , result .data .info .error .message )
179- console .error (' Attempts:' , result .data .info .error .retries )
177+ if (result .data .info .error ?.name === " StructuredOutputError" ) {
178+ console .error (" Failed to produce structured output:" , result .data .info .error .message )
179+ console .error (" Attempts:" , result .data .info .error .retries )
180180}
181181```
182182
@@ -298,27 +298,27 @@ const { providers, default: defaults } = await client.config.providers()
298298
299299### Sessions
300300
301- | Method | Description | Notes |
302- | ---------------------------------------------------------- | ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
303- | ` session.list() ` | List sessions | Returns <a href = { typesUrl } ><code >Session[ ] </code ></a > |
304- | ` session.get({ path }) ` | Get session | Returns <a href = { typesUrl } ><code >Session</code ></a > |
305- | ` session.children({ path }) ` | List child sessions | Returns <a href = { typesUrl } ><code >Session[ ] </code ></a > |
306- | ` session.create({ body }) ` | Create session | Returns <a href = { typesUrl } ><code >Session</code ></a > |
307- | ` session.delete({ path }) ` | Delete session | Returns ` boolean ` |
308- | ` session.update({ path, body }) ` | Update session properties | Returns <a href = { typesUrl } ><code >Session</code ></a > |
309- | ` session.init({ path, body }) ` | Analyze app and create ` AGENTS.md ` | Returns ` boolean ` |
310- | ` session.abort({ path }) ` | Abort a running session | Returns ` boolean ` |
311- | ` session.share({ path }) ` | Share session | Returns <a href = { typesUrl } ><code >Session</code ></a > |
312- | ` session.unshare({ path }) ` | Unshare session | Returns <a href = { typesUrl } ><code >Session</code ></a > |
313- | ` session.summarize({ path, body }) ` | Summarize session | Returns ` boolean ` |
314- | ` session.messages({ path }) ` | List messages in a session | Returns ` { info: ` <a href = { typesUrl } ><code >Message</code ></a >` , parts: ` <a href = { typesUrl } ><code >Part[ ] </code ></a >` }[] ` |
315- | ` session.message({ path }) ` | Get message details | Returns ` { info: ` <a href = { typesUrl } ><code >Message</code ></a >` , parts: ` <a href = { typesUrl } ><code >Part[ ] </code ></a >` } ` |
301+ | Method | Description | Notes |
302+ | ---------------------------------------------------------- | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
303+ | ` session.list() ` | List sessions | Returns <a href = { typesUrl } ><code >Session[ ] </code ></a > |
304+ | ` session.get({ path }) ` | Get session | Returns <a href = { typesUrl } ><code >Session</code ></a > |
305+ | ` session.children({ path }) ` | List child sessions | Returns <a href = { typesUrl } ><code >Session[ ] </code ></a > |
306+ | ` session.create({ body }) ` | Create session | Returns <a href = { typesUrl } ><code >Session</code ></a > |
307+ | ` session.delete({ path }) ` | Delete session | Returns ` boolean ` |
308+ | ` session.update({ path, body }) ` | Update session properties | Returns <a href = { typesUrl } ><code >Session</code ></a > |
309+ | ` session.init({ path, body }) ` | Analyze app and create ` AGENTS.md ` | Returns ` boolean ` |
310+ | ` session.abort({ path }) ` | Abort a running session | Returns ` boolean ` |
311+ | ` session.share({ path }) ` | Share session | Returns <a href = { typesUrl } ><code >Session</code ></a > |
312+ | ` session.unshare({ path }) ` | Unshare session | Returns <a href = { typesUrl } ><code >Session</code ></a > |
313+ | ` session.summarize({ path, body }) ` | Summarize session | Returns ` boolean ` |
314+ | ` session.messages({ path }) ` | List messages in a session | Returns ` { info: ` <a href = { typesUrl } ><code >Message</code ></a >` , parts: ` <a href = { typesUrl } ><code >Part[ ] </code ></a >` }[] ` |
315+ | ` session.message({ path }) ` | Get message details | Returns ` { info: ` <a href = { typesUrl } ><code >Message</code ></a >` , parts: ` <a href = { typesUrl } ><code >Part[ ] </code ></a >` } ` |
316316| ` session.prompt({ path, body }) ` | Send prompt message | ` body.noReply: true ` returns UserMessage (context only). Default returns <a href = { typesUrl } ><code >AssistantMessage</code ></a > with AI response. Supports ` body.outputFormat ` for [ structured output] ( #structured-output ) |
317- | ` session.command({ path, body }) ` | Send command to session | Returns ` { info: ` <a href = { typesUrl } ><code >AssistantMessage</code ></a >` , parts: ` <a href = { typesUrl } ><code >Part[ ] </code ></a >` } ` |
318- | ` session.shell({ path, body }) ` | Run a shell command | Returns <a href = { typesUrl } ><code >AssistantMessage</code ></a > |
319- | ` session.revert({ path, body }) ` | Revert a message | Returns <a href = { typesUrl } ><code >Session</code ></a > |
320- | ` session.unrevert({ path }) ` | Restore reverted messages | Returns <a href = { typesUrl } ><code >Session</code ></a > |
321- | ` postSessionByIdPermissionsByPermissionId({ path, body }) ` | Respond to a permission request | Returns ` boolean ` |
317+ | ` session.command({ path, body }) ` | Send command to session | Returns ` { info: ` <a href = { typesUrl } ><code >AssistantMessage</code ></a >` , parts: ` <a href = { typesUrl } ><code >Part[ ] </code ></a >` } ` |
318+ | ` session.shell({ path, body }) ` | Run a shell command | Returns <a href = { typesUrl } ><code >AssistantMessage</code ></a > |
319+ | ` session.revert({ path, body }) ` | Revert a message | Returns <a href = { typesUrl } ><code >Session</code ></a > |
320+ | ` session.unrevert({ path }) ` | Restore reverted messages | Returns <a href = { typesUrl } ><code >Session</code ></a > |
321+ | ` postSessionByIdPermissionsByPermissionId({ path, body }) ` | Respond to a permission request | Returns ` boolean ` |
322322
323323---
324324
0 commit comments