# GPT structured output and PDF input: JSON Schema and response_format Source: https://ofox.ai/docs/develop/models/gpt/structured-output This page covers structured output and PDF input for the GPT family. For model IDs and endpoint setup, see the [GPT family overview](https://ofox.ai/docs/develop/models/gpt). ## Structured output Pass a JSON Schema in `response_format`; with `strict: true`, the output strictly conforms to the schema: ```python filename="gpt_json_schema.py" import json import os from openai import OpenAI client = OpenAI(base_url="https://api.ofox.ai/v1", api_key=os.environ["OFOX_API_KEY"]) resp = client.chat.completions.create( model="openai/gpt-5.4-mini", response_format={ "type": "json_schema", "json_schema": { "name": "price", "strict": True, "schema": { "type": "object", "properties": {"price": {"type": "number"}, "currency": {"type": "string"}}, "required": ["price", "currency"], "additionalProperties": False, }, }, }, messages=[{"role": "user", "content": "A bat and a ball cost $1.10 in total. The bat costs $1 more than the ball. How much does the ball cost?"}], ) print(json.loads(resp.choices[0].message.content)) ``` For more patterns, see [Structured output](https://ofox.ai/docs/develop/guides/structured-output). ## PDF input **Chat Completions** ```python filename="gpt_pdf.py" import base64 import os from openai import OpenAI client = OpenAI(base_url="https://api.ofox.ai/v1", api_key=os.environ["OFOX_API_KEY"]) pdf_b64 = base64.b64encode(open("invoice.pdf", "rb").read()).decode() resp = client.chat.completions.create( model="openai/gpt-5.4-mini", messages=[{"role": "user", "content": [ {"type": "file", "file": {"filename": "invoice.pdf", "file_data": f"data:application/pdf;base64,{pdf_b64}"}}, {"type": "text", "text": "What is the total amount on this invoice?"}, ]}], ) print(resp.choices[0].message.content) ``` **Responses** ```python filename="gpt_pdf_responses.py" import base64 import os from openai import OpenAI client = OpenAI(base_url="https://api.ofox.ai/v1", api_key=os.environ["OFOX_API_KEY"]) pdf_b64 = base64.b64encode(open("invoice.pdf", "rb").read()).decode() resp = client.responses.create( model="openai/gpt-5.4-mini", input=[{"role": "user", "content": [ {"type": "input_file", "filename": "invoice.pdf", "file_data": f"data:application/pdf;base64,{pdf_b64}"}, {"type": "input_text", "text": "What is the total amount on this invoice?"}, ]}], ) print(resp.output_text) ``` For other errors, see [Common errors](https://ofox.ai/docs/develop/models/gpt#errors).