# Chat using Web Search — OpenAI (ChatGPT)

> Chat using the web search tool. See the documentation

- Key: `openai-chat-using-web-search`
- Type: Action (Read-only)
- Version: 0.0.10
- App: OpenAI (ChatGPT) (`openai`) — https://pipedream.com/apps/openai.md
- This page (HTML): https://pipedream.com/apps/openai/actions/chat-using-web-search
- Hints: read-only · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/openai/actions/chat-using-web-search/chat-using-web-search.mjs

## Description

Chat using the web search tool. [See the documentation](https://platform.openai.com/docs/guides/tools-web-search)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `modelId` | `string` | Yes | Model used to generate the response |
| `input` | `string` | Yes | Text inputs to the model used to generate a response |
| `instructions` | `string` | No | Inserts a system (or developer) message as the first item in the model's context |
| `previousResponseId` | `string` | No | The unique ID of the previous response to the model. Use this to create multi-turn conversations |
| `truncation` | `string` | No | Specifies the truncation mode for the response if it's larger than the context window size |
| `userLocation` | `string[]` | No | Additional configuration for approximate location parameters for the search |
| `searchContextSize` | `string` | No | Determines the amount of context to use during the web search |
| `responseFormat` | `string` | No | Text: Returns unstructured text output. JSON Schema: Enables you to define a specific structure for the model's output using a JSON schema. |
| `skipThisStep` | `boolean` | No | Pass in a boolean custom expression to skip this step's execution at runtime |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "openai",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "openai-chat-using-web-search",
  arguments: {
    modelId: "Model",
    input: "Chat Input",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "openai-chat-using-web-search",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    openai: { authProvisionId: "apn_xxxxxxx" },
    modelId: "Model",
    input: "Chat Input",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "openai-chat-using-web-search",
    "configured_props": {
      "openai": { "authProvisionId": "apn_xxxxxxx" },
      "modelId": "Model",
      "input": "Chat Input"
    }
  }'
```

---

- App: https://pipedream.com/apps/openai.md · All apps: https://pipedream.com/apps
