Example HTTP Request to Ozeki AI gateway

You can paste the command below into your terminal to run your first API request. Make sure to replace $OZEKI_API_KEY with your secret API key.

curl http://127.0.0.1:9511/api?command=chatgpt \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OZEKI_API_KEY" \
  -d '{
     "model": "AI_Chat_Bot_1@localhost",
     "messages": [
        {"role": "system", "content": "Transcript of a conversation between the 
        User and an Assistant. Assistant is a friendly, reliable, and highly 
        knowledgeable assistant, known for being helpful, empathetic, and honest. 
        Assistant consistently delivers prompt, clear, and accurate responses, 
        excelling in writing and problem-solving, ensuring the User's requests 
        are addressed with precision and care!"}
        {"role": "user", "content": "Hello"}
     	{"role": "assistant", "content": "How may I help you today?"}
     	{"role": "user", "content": "Where is London?"}
     ],
     "temperature": 0.7,
     "max_completion_tokens": 100
   }'

This request queries the AI_Chat_Bot_1@localhost (which under the hood points to a a local AI model) to complete the text starting with a prompt of "Say this is a test". You should get a response back that resembles the following:

{
   "id": "chatcmpl-XXHJWUKURSIARHTYHBAJIHUIFBCDX",
   "object": "chat.completion",
   "created": 1731676263,
   "model": "AI_Chat_Bot_1@localhost",
   "choices": [
     {
       "index": 0,
       "message": {
         "role": "assistant",
         "content": "London is the capital city of England 
         and the United Kingdom. It is located in southeastern 
         England on the River Thames.",
         "refusal": null
       },
       "logprobs": null,
       "finish_reason": "stop"
     }
   ],
   "usage": {
     "prompt_tokens": 0,
     "completion_tokens": 0,
     "total_tokens": 0,
     "completion_tokens_details": {
       "reasoning_tokens": 0
     }
   },
   "system_fingerprint": "fp_f85bea6784"
}

Now that you've generated your first chat completion, let's break down the response object. We can see the finish_reason is stop which means the API returned the full chat completion generated by the model without running into any limits. In the choices list, we only generated a single message but you can set the n parameter to generate multiple messages choices.

How to submit such an HTTP API request

You can test the above HTTP API request using the following tools:

  • Postman: A popular choice for API testing, offering intuitive authentication setup and comprehensive request testing.
  • Ozeki http client: A simple tool for API testing, offering HTTP GET and HTTP Post requests

More information