WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 0147dc8

Browse files
docs: add docs for shell tool (#10878)
docs weren't updated for the PR #10810 # Future Work - add docs for Apply Patch tool (needs some refactoring so follow up pr) --------- Co-authored-by: Nico Albanese <[email protected]>
1 parent 9ed4b65 commit 0147dc8

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

content/providers/01-ai-sdk-providers/03-openai.mdx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,45 @@ const result = await generateText({
600600
});
601601
```
602602

603+
#### Shell Tool
604+
605+
The OpenAI Responses API supports the shell tool for GPT-5.1 models through the `openai.tools.shell` tool.
606+
The shell tool allows allows running bash commands and interacting with a command line.
607+
The model proposes shell commands; your integration executes them and returns the outputs.
608+
609+
<Note type="warning">
610+
Running arbitrary shell commands can be dangerous. Always sandbox execution or
611+
add strict allow-/deny-lists before forwarding a command to the system shell.
612+
</Note>
613+
614+
```ts
615+
import { openai } from '@ai-sdk/openai';
616+
import { generateText } from 'ai';
617+
import { exec } from 'child_process';
618+
import { promisify } from 'util';
619+
620+
const execAsync = promisify(exec);
621+
622+
const result = await generateText({
623+
model: openai('gpt-5.1'),
624+
tools: {
625+
shell: openai.tools.shell({
626+
execute: async ({ action }) => {
627+
// ... your implementation, e.g. sandbox access ...
628+
return { output: results };
629+
},
630+
}),
631+
},
632+
prompt: 'List the files in the current directory and show disk usage.',
633+
});
634+
```
635+
636+
Your execute function must return an output array with results for each command:
637+
638+
- **stdout** _string_ - Standard output from the command
639+
- **stderr** _string_ - Standard error from the command
640+
- **outcome** - Either `{ type: 'timeout' }` or `{ type: 'exit', exitCode: number }`
641+
603642
#### Image Inputs
604643

605644
The OpenAI Responses API supports Image inputs for appropriate models.

0 commit comments

Comments
 (0)