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

# ChatGPT Integration

> Use refile in a ChatGPT GPT

You can use our ChatGPT integration to add refile functionality to a GPT. This allows ChatGPT to generate PDFs for you on the fly, with all the power of the refile API at it's fingertips.

<Note>
  This functionality is only available to ChatGPT Plus subscribers due to a
  limitation on OpenAIs end. You only need a Plus subscription to add and edit a
  GPT, you can keep using after you cancelled.
</Note>

## Creating a GPT with refile Integration

Follow these steps to create a GPT that can generate PDFs using refile:

1. Go to [ChatGPT](https://chat.openai.com/)
2. Click on "Explore GPTs" in the sidebar
3. Click "Create" in the top right
4. In the "Configure" tab, click "Add action"
5. Configure the action with the following settings:

**Authentication**

* Authentication Type: "API Key"
* API Key: (your api key)
* Auth Type: Bearer

**Schema**

Use this OpenAPI schema for your GPT:

```json [expandable] theme={null}
{
	"openapi": "3.1.0",
	"info": {
		"title": "refile API",
		"description": "API for converting Markdown to PDF with various styling options",
		"license": {
			"name": "MIT"
		},
		"version": "1.0.0"
	},
	"servers": [
		{
			"url": "https://www.refile.co/api/v1"
		}
	],
	"security": [
		{
			"bearerAuth": []
		}
	],
	"paths": {
		"/pdf/markdown": {
			"post": {
				"summary": "Generate PDF from Markdown",
				"operationId": "generatePdfFromMarkdown",
				"description": "Converts markdown content to PDF with customizable styling options.",
				"requestBody": {
					"description": "Markdown content and formatting options",
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/MarkdownPayload"
							}
						}
					},
					"required": true
				},
				"responses": {
					"200": {
						"description": "PDF generated successfully",
						"content": {
							"application/pdf": {
								"schema": {
									"type": "string",
									"format": "binary",
									"description": "Generated PDF file (when output=binary)"
								},
								"example": {
									"url": "https://files.refile.co/pdf/a1b2c3d4-e5f6-7g8h-9i0j-k1l2m3n4o5p6.pdf"
								}
							},
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/UrlResponse",
									"description": "URL to the generated PDF (when output=url)"
								}
							}
						}
					},
					"400": {
						"description": "Invalid request parameters",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"403": {
						"description": "Insufficient permissions or out of credits",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"413": {
						"description": "File size exceeds the limit for hosted files",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					},
					"500": {
						"description": "Server error",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		}
	},
	"components": {
		"schemas": {
			"MarkdownPayload": {
				"required": ["markdown", "output"],
				"type": "object",
				"properties": {
					"markdown": {
						"type": "string",
						"minLength": 1,
						"description": "The markdown content to convert to PDF."
					},
					"output": {
						"type": "string",
						"enum": ["url"],
						"default": "url",
						"description": "The format of the output. URL will return a direct link to the PDF."
					},
					"theme": {
						"type": "string",
						"enum": ["basic", "modern"],
						"default": "modern",
						"description": "The theme to use for the PDF."
					},
					"pageNumeration": {
						"type": "string",
						"enum": ["none", "center", "left", "right"],
						"default": "center",
						"description": "The position of the page numeration."
					},
					"pageSize": {
						"type": "string",
						"enum": [
							"A0",
							"A1",
							"A2",
							"A3",
							"A4",
							"A5",
							"A6",
							"A7",
							"A8",
							"A9",
							"Letter",
							"B1",
							"B2",
							"B3",
							"B4",
							"B5",
							"B6",
							"Ledger",
							"Legal",
							"Executive",
							"Folio",
							"Tabloid"
						],
						"default": "A4",
						"description": "The size of the page to use for the PDF."
					}
				}
			},
			"UrlResponse": {
				"type": "object",
				"properties": {
					"url": {
						"type": "string",
						"description": "URL to access the generated PDF"
					}
				}
			},
			"Error": {
				"type": "object",
				"properties": {
					"error": {
						"type": "string",
						"description": "Error message describing what went wrong"
					},
					"details": {
						"type": "object",
						"description": "Additional details about the error (if available)"
					},
					"message": {
						"type": "string",
						"description": "Error name or type (if available)"
					},
					"hint": {
						"type": "string",
						"description": "Suggested solution to fix the error (if available)"
					},
					"size": {
						"type": "string",
						"description": "File size information (for size-related errors)"
					}
				},
				"required": ["error"]
			}
		},
		"securitySchemes": {
			"bearerAuth": {
				"type": "http",
				"scheme": "bearer"
			}
		}
	}
}
```

6. Press the "Test" button on the action to make sure the generation works

7. For good measure, add the link to our privacy policy: [https://www.refile.co/legal/privacy](https://www.refile.co/legal/privacy)

8. Configure the remaining settings including the GPT name, description, and instructions according to your requirements to complete the setup process

<Tip>
  By pressing the GPTs name and selecting "Privacy Settings", you can enable
  "Always allow" to skip the prompts asking for permission to use refile!
</Tip>
