openai_responses_pdf_example

command
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

README

OpenAI Responses PDF Example

This example demonstrates how to use PDF files as input with the OpenAI Responses API.

Usage

Using a local PDF file
go run main.go -pdf path/to/your/document.pdf -prompt "What is the main topic of this document?"
Using an OpenAI file ID

First, upload your file to OpenAI and get the file ID, then:

go run main.go -file-id file-abc123 -prompt "Summarize the key points in this document"

Features

  • Supports both base64-encoded PDF data and OpenAI file IDs
  • Automatically handles file encoding and data URI formatting
  • Customizable prompts for different analysis tasks

Requirements

  • OpenAI API key set in OPENAI_API_KEY environment variable
  • Access to OpenAI's Responses API (currently in beta)

Example Prompts

  • "What is this document about? Provide a brief summary."
  • "Extract the key findings from this research paper."
  • "List the main sections and their topics."
  • "What are the conclusions or recommendations?"

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL