<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>FastAPI on Antoine Boucher</title><link>https://antoineboucher.info/CV/blog/tags/fastapi/</link><description>Recent content in FastAPI on Antoine Boucher</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Sat, 01 Jun 2024 10:00:00 -0400</lastBuildDate><atom:link href="https://antoineboucher.info/CV/blog/tags/fastapi/index.xml" rel="self" type="application/rss+xml"/><item><title>ChatGPT plugin with FastAPI — implementation outline</title><link>https://antoineboucher.info/CV/blog/posts/fastapi-chatgpt-plugin-overview/</link><pubDate>Sat, 01 Jun 2024 10:00:00 -0400</pubDate><guid>https://antoineboucher.info/CV/blog/posts/fastapi-chatgpt-plugin-overview/</guid><description>&lt;p&gt;OpenAI-style &lt;strong&gt;plugins&lt;/strong&gt; expose an HTTP API described by an &lt;strong&gt;OpenAPI&lt;/strong&gt; document so ChatGPT can call your tools safely. &lt;strong&gt;FastAPI&lt;/strong&gt; generates OpenAPI for you, which fits this model well.&lt;/p&gt;
&lt;h2 id="1-define-the-api-in-fastapi"&gt;1. Define the API in FastAPI&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Routes return &lt;strong&gt;JSON&lt;/strong&gt; with stable shapes (no ambiguous free text where structure matters).&lt;/li&gt;
&lt;li&gt;Add &lt;strong&gt;summaries and descriptions&lt;/strong&gt; on paths and fields — they help the model choose the right tool.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="2-publish-openapijson"&gt;2. Publish &lt;code&gt;openapi.json&lt;/code&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;FastAPI serves &lt;strong&gt;&lt;code&gt;/openapi.json&lt;/code&gt;&lt;/strong&gt; by default; the plugin manifest points at this URL (or a static copy you version).&lt;/li&gt;
&lt;li&gt;Keep schemas &lt;strong&gt;tight&lt;/strong&gt;: enums, required fields, and examples reduce bad calls.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="3-plugin-manifest"&gt;3. Plugin manifest&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Host &lt;strong&gt;&lt;code&gt;ai-plugin.json&lt;/code&gt;&lt;/strong&gt; (or the format required by the current OpenAI developer docs) over &lt;strong&gt;HTTPS&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Manifest references your API base URL and OpenAPI location.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="4-auth"&gt;4. Auth&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Prefer &lt;strong&gt;OAuth&lt;/strong&gt; or &lt;strong&gt;API keys&lt;/strong&gt; as documented for your integration; never commit secrets.&lt;/li&gt;
&lt;li&gt;Validate tokens inside FastAPI dependencies or middleware.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="5-deploy"&gt;5. Deploy&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;HTTPS&lt;/strong&gt; endpoint reachable from OpenAI’s servers.&lt;/li&gt;
&lt;li&gt;Logging and &lt;strong&gt;idempotency&lt;/strong&gt; for side-effecting routes.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="6-test-manually"&gt;6. Test manually&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Call routes with &lt;code&gt;curl&lt;/code&gt; or HTTPie using the same payloads the model will send.&lt;/li&gt;
&lt;li&gt;Iterate on descriptions and constraints before exposing wide traffic.&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;Details change with OpenAI’s platform updates — always follow the latest &lt;strong&gt;plugin / tools / actions&lt;/strong&gt; documentation when wiring production apps.&lt;/p&gt;</description></item></channel></rss>