Skip to main content
This API is deprecated. Follow the Completions V2 API tutorial instead.
This guide provides a practical, step-by-step guide for authenticating with the Gloo AI API and making a basic call to the Chat Completions endpoint. The process involves two main steps:
  1. Get an API Key: Create an API key in Gloo AI Studio.
  2. Make an API Call: Use the API key to make an authenticated request to the /chat/completions endpoint.

Prerequisites

Before starting, ensure you have:
The Completions API requires an API key for authentication.

Make a Chat Completion Call

Once you have a valid API key (using the authentication methods from the Authentication Tutorial), you can call the Completions API. The examples below show a basic request.

Complete Examples

The following examples combine the API key and the API call into a single, runnable script for each language. You’ll want to first set up your environment variables in either an .env file:
Or export them in your shell for Go and Java:

Working Code Sample

View Complete Code

Clone or browse the complete working examples for all 6 languages (JavaScript, TypeScript, Python, PHP, Go, Java) with setup instructions.

Next Steps

Now that you understand how to use the Completions API, consider exploring:
  1. Authentication Tutorial - For detailed authentication setup
  2. Completions API - For additional API information
  3. Chat Tutorial - For stateful chat interactions
  4. Tool Use - For enhanced completion capabilities