Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
kachiever
Participant
Welcome to the Second Episode of the Series: Hello World OpenAI: Crafting Accurate ChatGPT-Like Custom Search for SAPUI5 Application. So, in this episode, we will access our OpenAI account & try to access/test the API using our Access Token via Postman.


You can check all the existing & upcoming blog posts of this series via the introduction blog post available below link-

Click here

Prerequisites



  • I am assuming that you have a Trail Account Setup for OpenAI.

  • The link was shared in the Main Blog [Link], but sharing again here: Link


Install Postman


Many of you may already have POSTMAN installed on your machine. For those who are new, it is a Software / Tool that can be used to test API testing. It allows to create, test, and manage API requests.

You can download it from here: Link





Get Access Token from OpenAI


Step 1: Now let's follow this Link and log in to our OpenAI Account.

Step 2: You will land here, now select API.


Step 3: You will land here, click on your profile.


Step 4: Choose View API keys from the dropdown menu.


Step 5: Click on Create New Key.


Step 6: Choose any name & click on Create secret key.


Step 7: Your Secret Key is generated, Click & copy the same and save it somewhere (notepad) as you no longer will be able to access the same again.


Congratulations, we have successfully created the Secret Key to access OpenAI API. You will be able to see the same here.



Test OpenAI via Postman


Now we have Postman installed and OpenAI Secret token with us, it's time to test the service/connection.

Step 1: Open Postman & click on Workspace & choose Create Workspace.


Step 2: We will choose Blank workspace & click on Next.


Step 3: Choose a Name for the Workspace, add a description, make it Personal, & click on Create.


Step 4: You will land on the Overview Screen of your workspace, and click on the + Button.


Step 5: Click on Dropdown, choose POST Call & copy and paste the below URL in the URL box.
https://api.openai.com/v1/embeddings

Note: Don't worry we learn about this ahead & in detail in next episode.


Step 6: Time to use our Secret Key & add some config for our POST Call. Click on the Header add Authorization & Content-Type, and copy and paste both from below with respective values.
Authorization : Bearer [Secret Key]
Content-Type : application/json


Step 7:  Click on Body and choose raw & JSON. Now, copy-paste the below test body in Postman and click on send.
{
"input": "hello world",
"model": "text-embedding-ada-002"
}

Note: Don't worry we learn about this more in the next episode.


You will get the Below Response :

  • Response Code 200

  • JSON  Response with Embedding



Congratulations you have successfully Tested OpenAI's Embeddings API endpoint with Postman using the secret key that you created in your OpenAI Account.

Let's Summarize


Embeddings are vector representations of a given input that can be easily consumed by machine learning models and algorithms. OpenAI provides an API Endpoint to get these embeddings for an input. In this episode, we installed  POSTMAN to test this endpoint without actually creating any application. We created a Secret key in our OpenAI Account & used the same to Authenticate & consume the OpenAI endpoint. That's all for this episode, will meet you guys in Episode 3.

Next Episode : Epidosde 3

 

 
Labels in this area