OpenAI Built-in tools
OpenAI Built‑in tools lets you tap into OpenAI’s web search preview and image generation capabilities directly from your Nappai dashboard. You can provide a query or a file, choose the model and any additional instructions, and the component will return either a preview of search results or a generated image.
How it Works
The component talks to the OpenAI API.
- When you give it a query (the Input field) it calls the
web_search_preview
tool, which returns a short preview of relevant web pages. - If you want to generate an image, you select the
image_generation
tool and the component sends the prompt to OpenAI’s image generation endpoint. - For advanced use, you can attach a file to the File for Code Interpreter input and provide Assistant Instructions so the Code Interpreter can analyze the file and produce results.
All calls use the OpenAI Language Model you specify, and the component handles authentication with the API key you have stored in your environment.
Inputs
- File for Code Interpreter: The file to be analyzed by the Code Interpreter tool. Required only when
code_interpreter
is selected. - OpenAI Language Model: The language model to use for the batch chain. Must be an OpenAI language model.
- Assistant Instructions: Instructions for the Code Interpreter assistant. Only used when
code_interpreter
is selected. - Input: The input to search for.
- Built-in tool: The tools to use.
- Tool Name: The name of the tool. Required only when it is used as a tool.
Outputs
- Data: The raw data returned by the OpenAI tool (search preview, image URL, etc.).
- Tool: A ready‑to‑use tool object that can be passed to other components in the workflow.
Usage Example
- Drag the OpenAI Built‑in tools component onto your canvas.
- In the Built‑in tool field, select
web_search_preview
. - Enter a concise query in the Input field, e.g.,
latest AI trends 2024
. - Choose an OpenAI model in OpenAI Language Model (e.g.,
gpt-4o
). - Run the workflow. The component will return a short preview of relevant web pages in the Data output, which you can feed into a text‑analysis component or display to the user.
If you want to generate an image instead, choose image_generation
in Built‑in tool, provide a prompt in Input, and run. The Data output will contain the image URL.
Important Notes
🔒 Keep API key secure 🔴
Never expose your OpenAI API key in shared code or public repositories. Store it in secure environment variables or secret managers.
⚠️ Tool usage subject to OpenAI limits 🟡
Requests to web_search_preview
and image_generation
are limited by OpenAI’s usage quotas and rate limits. Excessive calls may result in temporary blocking.
📋 OpenAI API key needed 🔴
To use the OpenAI Built‑in tools you must have a valid OpenAI API key. The component will use the key you provide in your environment.
💡 Provide concise queries for web search 🟢
When using the web_search_preview
tool, use specific and focused queries to get the most relevant preview results and reduce unnecessary API usage.
💡 Use image_generation responsibly 🟡
Image generation outputs may be subject to content policies. Avoid requesting disallowed or copyrighted content and verify that generated images meet your use case.
ℹ️ Preview‑only search results 🟢
The web_search_preview
tool returns only a short preview of search results, not full web pages. If you need full content, follow up with a separate request.
Tips and Best Practices
- Keep your OpenAI API key in a secure environment variable.
- Use short, specific queries for web searches to stay within usage limits.
- Verify generated images against your content policy before using them.
- When using the Code Interpreter, provide clear instructions in Assistant Instructions to get the best results.
Security Considerations
- API Key Protection: Store the key in a secure vault or environment variable; never hard‑code it in your workflow.
- Rate Limits: Monitor your usage to avoid hitting OpenAI’s rate limits, which can temporarily block the component.
- Content Policies: Be aware of OpenAI’s content policy when generating images; disallowed content may be rejected or flagged.