Skip to content

Use OpenAI

The openai provider uses the OpenAI SDK’s first-party API defaults. ParseHawk stores the key encrypted and sends only inputs for extractors explicitly assigned to this provider.

Export the key in the shell where you run the CLI, then ask ParseHawk to encrypt and store it:

Terminal window
export OPENAI_API_KEY=...
parsehawk providers configure openai --api-key-env OPENAI_API_KEY

--api-key-env avoids placing the literal secret in shell history. The key is not returned by provider read endpoints.

List model IDs visible to the configured account:

Terminal window
parsehawk providers models openai

Assign an appropriate chat-completions model to a saved extractor:

Terminal window
parsehawk extractors update invoice_v1 \
--provider openai \
--model YOUR_MODEL_ID

ParseHawk requests structured JSON and streams the response. For image or PDF inputs, choose a model that accepts image content.

Terminal window
parsehawk start -x runtime

Only extractors assigned to openai send document data to OpenAI. Other extractors keep their own provider selection.

Run the configure command again to rotate it. To clear the stored value:

Terminal window
parsehawk providers configure openai --api-key ""

If you supply PARSEHAWK_SECRET_KEY, keep the same value available to API and worker processes; losing it makes stored provider keys unreadable.