> ## Documentation Index
> Fetch the complete documentation index at: https://docs.jinba.io/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenAI

> Invoke responses from OpenAI models

## Overview

OpenAI tools allow you to interact with OpenAI's language models, including GPT-3.5 and GPT-4. These tools support both simple text generation and structured output with JSON schemas.

## Key Features

* `OPENAI_INVOKE`
  * Send prompts to OpenAI models for text generation
  * Support for structured output with JSON schemas
* `OPENAI_INVOKE_WITH_FILE`
  * Send files along with prompts for file-based analysis
* `OPENAI_DEEP_RESEARCH`
  * Conduct autonomous, in-depth research using OpenAI's Deep Research models
  * Browses public sources with web search and synthesizes a comprehensive report
* `OPENAI_SORA2`
  * Generate videos with OpenAI's Sora models and receive a downloadable video URL

## Authentication

For further details, [click here](/en/pages/credentials/openai).

If you do not have an API key, you can still run OpenAI tools by using Jinba API credit. If you'd like to use your own API key, you can obtain one from the [OpenAI API website](https://platform.openai.com/api-keys).

**Note**: Treat API keys as sensitive information and never commit them to public repositories.

### Example: Basic Text Generation

```yaml theme={null}
- id: generate_summary
  name: generate_summary
  tool: OPENAI_INVOKE
  config:
    - name: version
      value: gpt-4
    - name: temperature
      value: 0.7
  input:
    - name: prompt
      value: |
        Please summarize the following text in 3 key points:
        
        {{steps.previous_step.result.content}}
```

### Example: Structured Output with JSON Schema

```yaml theme={null}
- id: extract_entities
  name: extract_entities
  tool: OPENAI_INVOKE
  config:
    - name: version
      value: gpt-4
    - name: temperature
      value: 0.1
  input:
    - name: prompt
      value: |
        Extract the following information from the text:
        - Names of people
        - Organizations
        - Locations
        - Dates
        
        Text: {{steps.input.result.content}}
    - name: json_schema
      value: |
        {
          "type": "object",
          "properties": {
            "entities": {
              "type": "object",
              "properties": {
                "people": {
                  "type": "array",
                  "items": {"type": "string"}
                },
                "organizations": {
                  "type": "array",
                  "items": {"type": "string"}
                },
                "locations": {
                  "type": "array",
                  "items": {"type": "string"}
                },
                "dates": {
                  "type": "array",
                  "items": {"type": "string"}
                }
              }
            }
          }
        }
```

### Example: File Analysis

```yaml theme={null}
- id: analyze_document
  name: analyze_document
  tool: OPENAI_INVOKE_WITH_FILE
  config:
    - name: version
      value: gpt-4
  input:
    - name: prompt
      value: |
        Please analyze this document and provide:
        1. A brief summary
        2. Key topics discussed
        3. Any action items or recommendations
    - name: file_link
      value: "{{steps.upload_file.result.url}}"
```

### Example: Deep Research

`OPENAI_DEEP_RESEARCH` runs long-form autonomous research. Available models are `o4-mini-deep-research-2025-06-26` (lightweight and faster, the default) and `o3-deep-research-2025-06-26` (optimized for in-depth synthesis and higher quality). Web search is enabled by default (`enable_web_search`), and you can optionally enable a code interpreter for data analysis (`enable_code_interpreter`). The research runs in background mode with polling; the `timeout_seconds` config controls how long to wait (default 3600 seconds). The final report is returned as `result.report`.

```yaml theme={null}
- id: market_research
  name: market_research
  tool: OPENAI_DEEP_RESEARCH
  config:
    - name: version
      value: o4-mini-deep-research-2025-06-26
    - name: reasoning_summary
      value: auto
  input:
    - name: research_query
      value: |
        Research the current landscape of AI workflow automation tools.
        Include major vendors, pricing models, and recent market trends.
    - name: system_instructions
      value: Focus on reputable industry sources and cite them inline.
    - name: enable_web_search
      value: true
- id: use_report
  name: use_report
  tool: OPENAI_INVOKE
  input:
    - name: prompt
      value: |
        Summarize the following research report in 5 bullet points:

        {{steps.market_research.result.report}}
```

### Example: Video Generation with Sora

`OPENAI_SORA2` generates a video from a text prompt, waits for completion, and returns a downloadable video URL (`result.video_url`, valid for 24 hours). You can choose the model (`sora-2` or `sora-2-pro`), the clip duration in seconds (`4`, `8`, or `12`), and the resolution (`720x1280`, `1280x720`, `1024x1792`, or `1792x1024`). An optional `image_reference` (JPEG, PNG, or WEBP) can be provided to guide the video.

```yaml theme={null}
- id: generate_video
  name: generate_video
  tool: OPENAI_SORA2
  input:
    - name: prompt
      value: A golden retriever puppy running through a field of sunflowers at sunset, cinematic lighting
    - name: model
      value: sora-2
    - name: seconds
      value: "8"
    - name: size
      value: "1280x720"
```
