Developer quickstart
Learn how to make your first API request.
The DevsDo.Code API provides a simple interface to state-of-the-art AI models for natural language processing, image generation, semantic search, and speech recognition. Follow this guide to learn how to generate human-like responses to natural language prompts, create vector embeddings for semantic search, and generate images from textual descriptions.
Create and export an API key
Create an API key in the dashboard here, which you'll use to securely access the API. Store the key in a safe location, like a .zshrc file or another text file on your computer. Once you've generated an API key, export it as an environment variable in your terminal.
Export an environment variable on macOS or Linux systems
export OPENAI_API_KEY="your_api_key_here"
Make your first API request
With your API key exported as an environment variable, you're ready to make your first API request. You can either use the REST API directly with the HTTP client of your choice, or use our official SDKs as shown below.
To use the API in server-side JavaScript environments like Node.js, Deno, or Bun, you can use our official SDK for TypeScript and JavaScript. Get started by installing the SDK:
npm install openai
With the SDK installed, create a file called example.mjs and copy the following example:
import OpenAI from "openai";
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
model: "gpt-4o-mini",
messages: [
{ role: "system", content: "You are a helpful assistant." },
{
role: "user",
content: "Write a haiku about recursion in programming.",
},
],
});
console.log(completion.choices[0].message);