You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: blog/ai/openai-rest-api-in-dotnet/index.html
+11-11Lines changed: 11 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -20,11 +20,11 @@
20
20
<meta property="og:type" content="website" />
21
21
<meta property="og:locale" content="en_US" /> -->
22
22
23
-
<!--Blazor:{"type":"webassembly","prerenderId":"0bf7c682d2664cc1a9803e312b6e94b8","key":{"locationHash":"77D12F14A8105320B1AAED6AE7E689DA0EC4483270A645E84079EAA0FFDF550D:0","formattedComponentKey":""},"assembly":"Microsoft.AspNetCore.Components.Web","typeName":"Microsoft.AspNetCore.Components.Web.HeadOutlet","parameterDefinitions":"W10=","parameterValues":"W10="}--><title>Using OpenAI APIs: Basic chat completions API Guide in .NET</title><metaproperty="og:url" content="http://127.0.0.1:5050/blog/ai/openai-rest-api-in-dotnet" />
23
+
<!--Blazor:{"type":"webassembly","prerenderId":"c5fe9ac39e874b29a59766668f6511e4","key":{"locationHash":"77D12F14A8105320B1AAED6AE7E689DA0EC4483270A645E84079EAA0FFDF550D:0","formattedComponentKey":""},"assembly":"Microsoft.AspNetCore.Components.Web","typeName":"Microsoft.AspNetCore.Components.Web.HeadOutlet","parameterDefinitions":"W10=","parameterValues":"W10="}--><title>Using OpenAI APIs: Basic chat completions API Guide in .NET</title><metaproperty="og:url" content="http://127.0.0.1:5050/blog/ai/openai-rest-api-in-dotnet" />
24
24
<metaproperty="og:title" content="Using OpenAI APIs: Basic chat completions API Guide in .NET" />
25
25
<metaproperty="og:description" content="Learn how to leverage OpenAI's powerful APIs to integrate AI capabilities into your applications. From authentication to implementation, discover everything you need to know about working with OpenAI APIs using direct HTTP requests." />
Imagine you're building a smart home system. Just as your system needs to communicate with various devices through specific protocols,
93
93
developers need to interact with AI models through APIs. OpenAI's APIs serve as this communication bridge, allowing you to harness
94
94
the power of advanced AI models like GPT-4 in your applications.
95
95
</p></div></section>
96
96
97
-
<sectionid="86a0b9ca-b840-4499-b9b6-fa82b272149d"><h4>What are OpenAI APIs?</h4><hrclass="border border-success border-1 opacity-50">
97
+
<sectionid="1a06cdeb-76ec-41d6-9991-da3af5c48695"><h4>What are OpenAI APIs?</h4><hrclass="border border-success border-1 opacity-50">
98
98
<div><p>
99
99
Imagine if you could add the magic of ChatGPT, DALL-E, or Whisper to your own apps—instantly making them smarter, more creative, and more helpful. That’s exactly what OpenAI APIs let you do! These are powerful, easy-to-use web services that unlock the same AI superpowers behind the tools everyone’s talking about.
With OpenAI APIs, you’re not just coding—you’re inventing the future. Whether you want to automate boring tasks, create something fun, or solve real problems, these APIs are your gateway to next-level innovation. The possibilities are endless and limited only by your imagination!
110
110
</p></div></section>
111
111
112
-
<sectionid="a23bdd28-0a23-4831-9998-969eba95ba7b"><h4>When to Use OpenAI APIs?</h4><hrclass="border border-success border-1 opacity-50">
112
+
<sectionid="cf7de1a1-3697-486a-acd8-53de035ea611"><h4>When to Use OpenAI APIs?</h4><hrclass="border border-success border-1 opacity-50">
113
113
<div><p>
114
114
Wondering when OpenAI APIs can make a real difference? Here are some moments where they shine—and you’ll probably recognize a few from your own life or work:
<sectionid="4b4e312e-f052-49b7-a458-428a0173d10f"><h3>How to Implement OpenAI APIs (API-based Approach)</h3><hrclass="border border-success border-1 opacity-50">
127
+
<sectionid="661ffe94-68c1-490c-8a9b-657284299c96"><h3>How to Implement OpenAI APIs (API-based Approach)</h3><hrclass="border border-success border-1 opacity-50">
128
128
<div><h4>1. Authentication: Getting and Securing Your API Key</h4>
129
129
<p><b>Authentication</b> is required for every OpenAI API call. You must use a secret API key, which you can generate from your <ahref="https://platform.openai.com/api-keys" target="_blank">OpenAI dashboard</a>.
<sectionid="2de0ecdf-f509-4d0c-abf4-a4b47fe45509"><h3>🎬 Demo: Movie Summary Generator</h3><hrclass="border border-success border-1 opacity-50">
221
+
<sectionid="6d6a66fd-25ff-4d66-8044-3cdd261deb26"><h3>🎬 Demo: Movie Summary Generator</h3><hrclass="border border-success border-1 opacity-50">
222
222
<div><p><b>How to use this demo:</b> Enter your personal OpenAI API key (you can create one from your <ahref="https://platform.openai.com/api-keys" target="_blank">OpenAI dashboard</a>) in the first field. Then, type the name of any movie you want summarized in the second field. Click <b>Get Summary</b> and the AI will generate a short summary of the movie using OpenAI's API. Your API key is never stored or sent anywhere except directly to OpenAI for this request.
223
223
</p>
224
224
<divclass="mb-3"><labelfor="apiKeyInput" class="form-label"><b>Enter your OpenAI API key:</b></label>
<div><b>OpenAI response:</b><br><divclass="card mt-2" style="background-color: #f8f9fa; border: 1px solid #e9ecef;"><divclass="card-body"><span>Response will appear here after you enter your API key and movie name.</span></div></div></div></div></section>
<div><ul><li><b>Never hardcode your API key!</b> Treat it like your password—use environment variables or a secure vault. One accidental push to GitHub can expose your account.</li>
234
234
<li><b>Expect the unexpected.</b> Always handle errors gracefully. Network hiccups, expired keys, or API changes can happen—show helpful messages, not cryptic errors.</li>
235
235
<li><b>Watch your usage and costs.</b> OpenAI APIs are powerful, but not free. Set usage limits, monitor your dashboard, and consider caching frequent responses to save money.</li>
0 commit comments