How to config OpenAI API on my Control

Jingyue IFun 0 Reputation points
2025-09-28T06:22:27.2+00:00

How to configure the OpenAI API in the console so that it can call AI services through network requests

Foundry Tools
Foundry Tools

Formerly known as Azure AI Services or Azure Cognitive Services is a unified collection of prebuilt AI capabilities within the Microsoft Foundry platform

0 comments No comments

2 answers

Sort by: Most helpful
  1. Anshika Varshney 15,535 Reputation points Microsoft External Staff Moderator
    2025-09-29T20:29:58.7666667+00:00

    Hello Jingyue IFun,

    Thank you for reaching out on the Microsoft Q&A.

    To use the OpenAI API from your console, make sure your Azure account has the Cognitive Services OpenAI Contributor role on the resource. This gives u permission to call AI services.

    Next, authenticate your session with the Azure CLI using az login. This connects your console to your Azure account for authorized requests.

    You can then call the Inference API (for generating text, embeddings, etc.) or the Ingestion API if u need to manage data.

    Finally, always keep your API keys secure, storing them in Azure Key Vault is recommended instead of hardcoding them.

    Following these steps lets u safely and smoothly configure the OpenAI API for network requests.

    References:

    If you feel that your quires have been resolved, please accept the answer by clicking the "Upvote" and "Accept Answer" on the post.

    Thank you!

    Was this answer helpful?


  2. Sina Salam 31,376 Reputation points Volunteer Moderator
    2025-09-28T16:39:50.53+00:00

    Hello Jingyue IFun,

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    I understand that you would like to configure the OpenAI API in the console application to call AI services through network requests.

    The following are the best practices procedures to follow:

    1. Create an OpenAI Account and Get API Key:
      • Go to OpenAI Platform.
      • Sign in and navigate to API Keys.
      • Generate a secret API key (keep it safe; do not expose it in client-side code).
    2. Store your API key securely in an environment variable instead of hardcoding it: setx OPENAI_API_KEY "your_api_key_here" Then set environment variable (.env file): OPENAI_API_KEY=your_api_key_here
    3. Install OpenAI SDK or Use HTTP Requests: You can use the official OpenAI SDK or make raw HTTP requests. You can have:
      • Option A: Using OpenAI SDK
      • Option B: Using cURL
    4. Then, configure in your Console or App appsettings.json or environment variables, to have If the API key, then inject it into your HTTP client. Even for JavaScript/Node.js, use dotenv to load the key and call the API with fetch or axios.
    5. Ensure your server or console app has internet access and if behind a firewall, whitelist api.openai.com on port 443 for network access.

    Use the following tutorials and links to see how you can achieve the above steps and procedures in different ways of coding:

    I hope this is helpful! Do not hesitate to let me know if you have any other questions or clarifications.


    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.