### NestJS Guide: Project Setup and Core Concepts (TypeScript/Bash) Source: https://docs.aimlapi.com/capabilities/batch-processing This snippet provides a guide for learning NestJS, covering project setup with the NestJS CLI, core concepts like Modules, Controllers, Services, and Dependency Injection, along with decorators and middleware. It also touches upon validation, database integration, authentication, and resources for further learning. The code examples are in TypeScript, with setup commands in Bash. ```bash # Install NestJS CLI globally npm i -g @nestjs/cli # Create a new project nest new project-name # Navigate to project directory cd project-name # Run the application npm run start # Install class-validator npm i class-validator class-transformer # For TypeORM npm i @nestjs/typeorm typeorm postgres # Install passport npm i @nestjs/passport passport passport-local ``` ```typescript @Module({ controllers: [], providers: [], imports: [] }) export class AppModule {} @Controller('users') export class UsersController { @Get() findAll() { return 'List of users'; } @Post() create(@Body() createUserDto: CreateUserDto) { return 'Create user'; } } @Injectable() export class UsersService { findAll() { return ['user1', 'user2']; } create(user) { // Create user logic } } @Controller('users') export class UsersController { constructor(private usersService: UsersService) {} } // Common decorators @Module() @Controller() @Injectable() @Get() @Post() @Put() @Delete() @Param() @Body() @Query() @Injectable() export class LoggerMiddleware implements NestMiddleware { use(req: Request, res: Response, next: NextFunction) { console.log('Request...'); next(); } } export class CreateUserDto { @IsNotEmpty() @IsString() name: string; @IsEmail() email: string; } // user.dto.ts export class CreateUserDto { @IsNotEmpty() username: string; @IsEmail() email: string; } // user.entity.ts @Entity() ``` -------------------------------- ### API Call Setup Guide Source: https://docs.aimlapi.com/api-references/text-models-llm/alibaba-cloud/qwen3-next-80b-a3b-thinking Instructions on how to set up your environment and make the first API call to the qwen3-next-80b-a3b-thinking model. ```APIDOC ## How to make the first API call **1. Required Setup:** - **Create an account:** Sign up on the AI/ML API website. - **Generate an API key:** Create an API key in your account dashboard and ensure it is enabled. **2. Copy the code example:** Select the code snippet for your preferred programming language (Python/Node.js) from the bottom of this page. **3. Update the snippet:** - Replace `` with your actual AI/ML API key. - Set the `model` field to `alibaba/qwen3-next-80b-a3b-thinking`. - Provide the necessary input fields (e.g., `messages` for chat models). **4. (Optional) Tune the request:** Adjust optional parameters to control output generation, quality, and length as per the API schema. **5. Run your code:** Execute the updated code in your development environment. Response times vary based on the model and request size. ``` -------------------------------- ### Making an API Call (Python SDK Example) Source: https://docs.aimlapi.com/quickstart/setting-up Example of making an API call using the OpenAI SDK in Python with the AIML API. ```APIDOC ## Making an API Call (Python SDK Example) This example demonstrates how to make an API call using the OpenAI SDK in Python, configured for the AIML API. ### Method N/A (Illustrative Code) ### Endpoint N/A (Illustrative Code) ### Request Body ```python from openai import OpenAI base_url = "https://api.aimlapi.com/v1" # Replace with your actual AIML API Key api_key = "" client = OpenAI(base_url=base_url, api_key=api_key) # Example of a chat completion call response = client.chat.completions.create( model="gpt-4o", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Who won the world series in 2020?"} ] ) print(response.choices[0].message.content) ``` ### Request Example (See code block above for full example) ### Response #### Success Response (200) - **content** (string) - The response from the model. #### Response Example ```json { "id": "chatcmpl-20240515093818-abcdef123456", "object": "chat.completion", "created": 1715755098, "model": "gpt-4o", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020." }, "logprobs": null, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 24, "completion_tokens": 13, "total_tokens": 37 }, "system_fingerprint": "fp_a0f41b5f76" } ``` ``` -------------------------------- ### Install OpenAI SDK with pip Source: https://docs.aimlapi.com/quickstart/setting-up Installs the OpenAI SDK, a necessary dependency for interacting with the AIMLAPI. This command is typically run in a Python virtual environment. ```shell pip install openai ``` -------------------------------- ### Install and Run ElizaOS Starter Project Source: https://docs.aimlapi.com/integrations/elizaos This bash script outlines the steps to clone the ElizaOS starter repository, set up environment variables, install dependencies, build the project, and start the ElizaOS application. Ensure you have `bun` and `Node.js` (v18+) installed. ```bash git clone cd eliza-starter cp .env.example .env bun i && bun run build && bun start ``` -------------------------------- ### NodeJS Project Initialization and Dependency Installation Source: https://docs.aimlapi.com/quickstart/setting-up Initializes a new NodeJS project using 'npm init -y' and installs the 'openai' package, which is required for interacting with the AIMLAPI. This sets up the project structure and necessary libraries. ```bash npm init -y npm i openai ``` -------------------------------- ### Qwen-Plus Model Integration Source: https://docs.aimlapi.com/api-references/text-models-llm/alibaba-cloud/qwen-plus This section provides instructions and examples for integrating the qwen-plus model into your applications. It covers API key setup, model selection, and request formatting. ```APIDOC ## Qwen-Plus Model API Documentation ### Description This documentation outlines the usage of the `qwen-plus` model via the AI/ML API. It includes setup instructions, API schema, and example calls. ### Method POST ### Endpoint /v1/chat/completions ### Parameters #### Query Parameters - **model** (string) - Required - The identifier for the model to use. For this documentation, it is `qwen-plus`. #### Request Body - **messages** (array) - Required - An array of message objects, representing the conversation history. - **role** (string) - Required - The role of the author of the message ('system', 'user', or 'assistant'). - **content** (string) - Required - The content of the message. - **temperature** (number) - Optional - Controls randomness. Lower values make the output more focused and deterministic. - **max_tokens** (integer) - Optional - The maximum number of tokens to generate in the completion. ### Request Example ```json { "model": "qwen-plus", "messages": [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is the capital of France?"} ], "temperature": 0.7, "max_tokens": 100 } ``` ### Response #### Success Response (200) - **id** (string) - Unique identifier for the completion. - **object** (string) - Type of object returned ('chat.completion'). - **created** (integer) - Unix timestamp of when the completion was created. - **model** (string) - The model used for the completion. - **choices** (array) - A list of completion choices. - **index** (integer) - Index of the choice. - **message** (object) - The message content. - **role** (string) - The role of the author ('assistant'). - **content** (string) - The generated text. - **finish_reason** (string) - The reason the model stopped generating tokens ('stop', 'length', etc.). - **usage** (object) - Usage statistics for the request. - **prompt_tokens** (integer) - Number of tokens in the prompt. - **completion_tokens** (integer) - Number of tokens in the completion. - **total_tokens** (integer) - Total tokens used. #### Response Example ```json { "id": "chatcmpl-12345", "object": "chat.completion", "created": 1677652288, "model": "qwen-plus", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "The capital of France is Paris." }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 10, "completion_tokens": 5, "total_tokens": 15 } } ``` ``` -------------------------------- ### Qwen2.5-Coder-32B-Instruct Model Documentation Source: https://docs.aimlapi.com/api-references/text-models-llm/alibaba-cloud/qwen2 This section details the Qwen2.5-Coder-32B-Instruct model, its capabilities, and how to interact with it through the AI/ML API. It includes setup instructions, API key generation, and code examples for making API calls. ```APIDOC ## Qwen2.5-Coder-32B-Instruct Model Overview ### Description The 32B variant of the latest code-focused model series (formerly CodeQwen). The most capable, with strong performance in coding, math, and general tasks. ### Getting Started 1. **Account Creation**: Sign up on the AI/ML API website. 2. **API Key Generation**: Create an enabled API key in your account dashboard. 3. **Code Snippet**: Copy the provided code example (Python/Node.js) and update it with your API key, desired model, and input. 4. **Tuning**: Optionally add parameters to control output. 5. **Execution**: Run the code. Refer to the [Quickstart guide](https://docs.aimlapi.com/quickstart/setting-up) for a detailed walkthrough. ### API Schema (API Schema details would typically follow here, describing available endpoints, parameters, and response formats for interacting with this model. Since no specific endpoints are detailed in the provided text, this section is left as a placeholder.) ``` -------------------------------- ### Generate AI Response with Text Input (OpenAPI) Source: https://docs.aimlapi.com/api-references/text-models-llm/openai/gpt-5-nano This snippet demonstrates how to use the POST /v1/responses endpoint with a text input. It specifies the AI model and provides a simple text prompt to generate a response. This is a basic example for getting started with the API. ```json { "model": "openai/gpt-5-nano-2025-08-07", "input": { "role": "user", "content": { "type": "message", "content": [ { "type": "input_text", "text": "Hello, world!" } ] } } } ``` -------------------------------- ### Install Python 3 on Ubuntu (Bash) Source: https://docs.aimlapi.com/faq/can-i-use-api-in-python This code installs Python 3 and the virtual environment package on Ubuntu systems. Ensure Python is not already installed before running these commands. ```bash sudo apt update sudo apt install -y python3-venv ``` -------------------------------- ### Grok-4.1 Fast Non-Reasoning API Call Source: https://docs.aimlapi.com/api-references/text-models-llm/xai/grok-4-1-fast-non-reasoning This section provides an example of how to make an API call to the grok-4.1-fast-non-reasoning model. It includes setup instructions, code examples in various languages, and details on request parameters. ```APIDOC ## POST /v1/chat/completions ### Description This endpoint is used to interact with the grok-4.1-fast-non-reasoning model to get text completions based on provided messages. ### Method POST ### Endpoint `/v1/chat/completions` ### Parameters #### Request Body - **model** (string) - Required - The model to use for completion. For this documentation, it is `x-ai/grok-4-1-fast-non-reasoning`. - **messages** (array) - Required - An array of message objects, each with a `role` and `content`. - **role** (string) - Required - The role of the author of the message (`user` or `assistant`). - **content** (string) - Required - The content of the message. - **temperature** (number) - Optional - Controls randomness. Lower values make the output more focused and deterministic. - **max_tokens** (integer) - Optional - The maximum number of tokens to generate in the completion. ### Request Example ```json { "model": "x-ai/grok-4-1-fast-non-reasoning", "messages": [ { "role": "user", "content": "What is the weather today?" } ] } ``` ### Response #### Success Response (200) - **choices** (array) - An array of completion choices. - **message** (object) - The message content and role. - **role** (string) - The role of the assistant. - **content** (string) - The generated text content. - **usage** (object) - Information on token usage. - **prompt_tokens** (integer) - Number of tokens in the prompt. - **completion_tokens** (integer) - Number of tokens in the completion. - **total_tokens** (integer) - Total tokens used. #### Response Example ```json { "choices": [ { "message": { "role": "assistant", "content": "The weather today is sunny with a high of 75 degrees Fahrenheit." } } ], "usage": { "prompt_tokens": 10, "completion_tokens": 20, "total_tokens": 30 } } ``` ``` -------------------------------- ### Python AIMLAPI Chat Completion Example Source: https://docs.aimlapi.com/quickstart/setting-up A Python script demonstrating how to use the OpenAI SDK to interact with the AIMLAPI. It sets up the API key, base URL, system and user prompts, sends a chat completion request, and prints the AI's response. Ensure you replace '' with your actual API key. ```python from openai import OpenAI base_url = "https://api.aimlapi.com/v1" api_key = "" system_prompt = "You are a travel agent. Be descriptive and helpful." user_prompt = "Tell me about San Francisco" api = OpenAI(api_key=api_key, base_url=base_url) def main(): completion = api.chat.completions.create( model="gpt-4o", messages=[ {"role": "system", "content": system_prompt}, {"role": "user", "content": user_prompt}, ], temperature=0.7, max_tokens=256, ) response = completion.choices[0].message.content print("User:", user_prompt) print("AI:", response) if __name__ == "__main__": main() ``` -------------------------------- ### Example Knowledge Structure Output Source: https://docs.aimlapi.com/solutions/bagoodex/ai-search-engine/get-a-knowledge-structure An example of the structured knowledge returned for a query, typically containing details like title, type, description, and birth/death dates. ```json { 'title': 'Nikola Tesla', 'type': 'Engineer and futurist', 'description': None, 'born': 'July 10, 1856, Smiljan, Croatia', 'died': 'January 7, 1943 (age 86 years), The New Yorker A Wyndham Hotel, New York, NY' } ``` -------------------------------- ### Check Python Installation (Bash) Source: https://docs.aimlapi.com/faq/can-i-use-api-in-python This snippet demonstrates how to check if Python is installed on your system by executing version commands in the terminal. It covers common commands for different operating systems. ```bash python3 --version python --version py --version ``` -------------------------------- ### AIML API Key Generation Source: https://docs.aimlapi.com/quickstart/setting-up Instructions on how to generate an AIML API key from your account page. ```APIDOC ## Generating an AIML API Key To use the AIML API, you need to create an account and generate an API key. 1. **Create an Account:** Visit the [AI/ML API website](https://aimlapi.com/app/sign-up) and create an account. 2. **Generate an API Key:** After logging in, navigate to your account dashboard ([https://aimlapi.com/app/keys](https://aimlapi.com/app/keys)) and generate your API key. Ensure that key is enabled on UI. An AIML API Key is a credential that grants you access to our API. It should be kept confidential and not shared. ``` -------------------------------- ### Make API Call using Python (OpenAI SDK) Source: https://docs.aimlapi.com/quickstart/setting-up This Python snippet demonstrates making an API call using the OpenAI SDK. It requires the 'openai' library and your AIML API key. The base URL is configured to point to the AI/ML API. ```python from openai import OpenAI base_url = "https://api.aimlapi.com/v1" ``` -------------------------------- ### Create OpenAI SDK Instance Source: https://docs.aimlapi.com/quickstart/setting-up Instantiates the OpenAI SDK client, providing the API key and base URL for authentication and endpoint configuration. This object is used to make subsequent API calls. Supported languages include JavaScript and Python. ```javascript const api = new OpenAI({ apiKey, baseURL, }); ``` ```python api = OpenAI(api_key=api_key, base_url=base_url) ``` -------------------------------- ### Display AI/ML API Conversation Output Source: https://docs.aimlapi.com/quickstart/setting-up This code illustrates how to print the user's prompt and the AI's generated response, simulating a conversation. It's a common pattern for displaying interaction history with AI models. Ensure the 'userPrompt' and 'response' variables are correctly populated before execution. ```javascript console.log("User:", userPrompt); console.log("AI:", response); ``` ```python print("User:", user_prompt) print("AI:", response) ``` -------------------------------- ### Install AI/ML API Node via npm for Self-Hosted n8n Source: https://docs.aimlapi.com/integrations/n8n This command installs the AI/ML API node package for n8n. This is used in self-hosted n8n setups where manual dependency management is preferred. Ensure you are in your self-hosted n8n directory before running the command. After installation, n8n needs to be restarted for the new node to be registered. ```bash npm install n8n-nodes-aimlapi ``` -------------------------------- ### Initialize OpenAI Client (Python) Source: https://docs.aimlapi.com/solutions/openai/assistants Establishes a connection to the OpenAI API using an AIMLAPI key and base URL. This is the first step to interact with any OpenAI services. ```python import openai from openai import OpenAI # Connect to OpenAI API client = OpenAI( api_key="", base_url="https://api.aimlapi.com/" ) ``` -------------------------------- ### Mistral Tiny Model API Source: https://docs.aimlapi.com/api-references/text-models-llm/mistral-ai/mistral-tiny This section details how to make a call to the mistral-tiny model, including setup instructions and an example API schema. ```APIDOC ## Mistral Tiny Model API Endpoint ### Description This endpoint allows you to interact with the mistral-tiny language model for tasks such as text generation, summarization, and code completion. ### Method POST ### Endpoint `/v1/chat/completions` ### Parameters #### Request Body - **model** (string) - Required - The model to use for the request (e.g., `mistralai/mistral-tiny`). - **messages** (array) - Required - An array of message objects, where each object has a `role` (e.g., `user`, `assistant`, `system`) and `content` (string). - **temperature** (number) - Optional - Controls randomness. Lower values make the output more deterministic. - **max_tokens** (integer) - Optional - The maximum number of tokens to generate in the completion. - **stream** (boolean) - Optional - Whether to stream the response. ### Request Example ```json { "model": "mistralai/mistral-tiny", "messages": [ {"role": "user", "content": "What is the weather like today?"} ], "temperature": 0.7, "max_tokens": 100 } ``` ### Response #### Success Response (200) - **id** (string) - The ID of the completion. - **object** (string) - The type of object returned. - **created** (integer) - The Unix timestamp of when the completion was created. - **model** (string) - The model used for the completion. - **choices** (array) - An array of completion choices. - **index** (integer) - The index of the choice. - **message** (object) - The message object. - **role** (string) - The role of the message (e.g., `assistant`). - **content** (string) - The content of the message. - **finish_reason** (string) - The reason the model finished generating the completion. - **usage** (object) - Information about token usage. - **prompt_tokens** (integer) - The number of tokens in the prompt. - **completion_tokens** (integer) - The number of tokens in the completion. - **total_tokens** (integer) - The total number of tokens used. #### Response Example ```json { "id": "chatcmpl-xxxxxxxxxxxxxxxxx", "object": "chat.completion", "created": 1677652288, "model": "mistralai/mistral-tiny", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "I cannot provide real-time weather information." }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 10, "completion_tokens": 8, "total_tokens": 18 } } ``` ``` -------------------------------- ### Set Up Virtual Environment and Install Dependencies Source: https://docs.aimlapi.com/integrations/agno Provides commands to create and activate a Python virtual environment, export an API key, and install necessary libraries for using Agno with AIML API, including openai, duckduckgo-search, duckdb, yfinance, and agno. ```bash python3 -m venv ~/.venvs/aienv source ~/.venvs/aienv/bin/activate export AIMLAPI_API_KEY=*** pip install -U openai duckduckgo-search duckdb yfinance agno ``` -------------------------------- ### Initialize API Credentials and Prompts Source: https://docs.aimlapi.com/quickstart/setting-up Sets up essential variables for API interaction, including the base URL, API key, and system/user prompts. These variables define the API endpoint and the context for the AI model's response. Supported languages include JavaScript and Python. ```javascript const baseURL = "https://api.aimlapi.com/v1"; const apiKey = ""; const systemPrompt = "You are a travel agent. Be descriptive and helpful"; const userPrompt = "Tell me about San Francisco"; ``` ```python base_url = "https://api.aimlapi.com/v1" api_key = "" system_prompt = "You are a travel agent. Be descriptive and helpful." user_prompt = "Tell me about San Francisco" ``` -------------------------------- ### Python Example: Get Knowledge Structure Source: https://docs.aimlapi.com/solutions/bagoodex/ai-search-engine/get-a-knowledge-structure Demonstrates how to retrieve structured knowledge using the AI Search Engine API. It involves a two-step process: first calling the chat completion endpoint to get a followup ID, then using that ID with the knowledge retrieval endpoint. Requires the 'requests' and 'openai' libraries. ```python import requests from openai import OpenAI # Insert your AIML API Key instead of : API_KEY = '' API_URL = 'https://api.aimlapi.com' # Call the standart chat completion endpoint to get an ID def complete_chat(): client = OpenAI( base_url=API_URL, api_key=API_KEY, ) response = client.chat.completions.create( model="bagoodex/bagoodex-search-v1", messages=[ { "role": "user", "content": "Who is Nicola Tesla", }, ], ) # Extract the ID from the response gen_id = response.id print(f"Generated ID: {gen_id}") # Call the second endpoint with the generated ID get_knowledge(gen_id) def get_knowledge(gen_id): params = {'followup_id': gen_id} headers = {'Authorization': f'Bearer {API_KEY}'} response = requests.get(f'{API_URL}/v1/bagoodex/knowledge', headers=headers, params=params) print(response.json()) # Run the function complete_chat() ``` -------------------------------- ### Make API Call using NodeJS (OpenAI SDK) Source: https://docs.aimlapi.com/quickstart/setting-up This NodeJS snippet shows how to make an API call using the OpenAI SDK. It requires the 'openai' package and your AIML API key. The base URL is set to the AI/ML API endpoint. ```javascript import OpenAI from 'openai'; const openai = new OpenAI({ apiKey: "", baseURL: "https://api.aimlapi.com/v1", }); ``` -------------------------------- ### nemotron-nano-9b-v2 API Endpoint Source: https://docs.aimlapi.com/api-references/text-models-llm/nvidia/nemotron-nano-9b-v2 This section details how to make a call to the nemotron-nano-9b-v2 model API. It includes setup instructions, code examples, and parameter explanations. ```APIDOC ## POST /v1/chat/completions ### Description This endpoint allows you to interact with the nemotron-nano-9b-v2 model to generate responses based on your provided prompts. ### Method POST ### Endpoint /v1/chat/completions ### Parameters #### Query Parameters - **model** (string) - Required - The model to use for the request. For this documentation, it should be `nvidia/nemotron-nano-9b-v2`. #### Request Body - **messages** (array) - Required - An array of message objects, each with a `role` and `content` field. - **role** (string) - Required - The role of the author of the message (`user` or `assistant`). - **content** (string) - Required - The content of the message. - **temperature** (number) - Optional - Controls randomness. Lower values make the output more deterministic. - **max_tokens** (integer) - Optional - The maximum number of tokens to generate in the response. - **top_p** (number) - Optional - Controls diversity via nucleus sampling. An alternative to sampling with temperature. ### Request Example ```json { "model": "nvidia/nemotron-nano-9b-v2", "messages": [ { "role": "user", "content": "What is the weather like today?" } ], "temperature": 0.7, "max_tokens": 150 } ``` ### Response #### Success Response (200) - **choices** (array) - An array of response choices. - **message** (object) - The message content. - **role** (string) - The role of the author (`assistant`). - **content** (string) - The generated response from the model. - **usage** (object) - Information about token usage. - **prompt_tokens** (integer) - Number of tokens in the prompt. - **completion_tokens** (integer) - Number of tokens in the completion. - **total_tokens** (integer) - Total tokens used. #### Response Example ```json { "choices": [ { "message": { "role": "assistant", "content": "The weather today is sunny with a high of 75 degrees Fahrenheit." } } ], "usage": { "prompt_tokens": 10, "completion_tokens": 15, "total_tokens": 25 } } ``` ``` -------------------------------- ### Nemotron-Nano-12B-v2-VL Model Interaction Source: https://docs.aimlapi.com/api-references/text-models-llm/nvidia/llama-3 This section provides an example of how to interact with the Nemotron-Nano-12B-v2-VL model. It includes instructions on setup, API key generation, and structuring the request. ```APIDOC ## POST /v1/chat/completions ### Description This endpoint allows you to interact with the Nemotron-Nano-12B-v2-VL model to perform tasks such as document understanding and summarization. ### Method POST ### Endpoint /v1/chat/completions ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **model** (string) - Required - The model identifier, e.g., `nvidia/nemotron-nano-12b-v2-vl`. - **messages** (array) - Required - An array of message objects representing the conversation history. - **role** (string) - Required - The role of the author. Options: `system`, `user`, `assistant`. - **content** (string) - Required - The content of the message. - **temperature** (number) - Optional - Controls randomness. Lower values make the output more deterministic. - **max_tokens** (integer) - Optional - The maximum number of tokens to generate. ### Request Example ```json { "model": "nvidia/nemotron-nano-12b-v2-vl", "messages": [ { "role": "user", "content": "Summarize the following document: [Your document content here]" } ], "temperature": 0.7, "max_tokens": 500 } ``` ### Response #### Success Response (200) - **id** (string) - Unique identifier for the response. - **object** (string) - Type of the object, e.g., `chat.completion`. - **created** (integer) - Unix timestamp of when the response was created. - **model** (string) - The model used for the response. - **choices** (array) - An array of completion choices. - **index** (integer) - Index of the choice. - **message** (object) - The message object. - **role** (string) - The role of the message author (e.g., `assistant`). - **content** (string) - The content of the assistant's message. - **finish_reason** (string) - The reason the model stopped generating tokens. - **usage** (object) - Usage statistics. - **prompt_tokens** (integer) - Number of tokens in the prompt. - **completion_tokens** (integer) - Number of tokens in the completion. - **total_tokens** (integer) - Total number of tokens. #### Response Example ```json { "id": "chatcmpl-xxxxxxxxxxxxxxxxxxxxxxxxx", "object": "chat.completion", "created": 1700000000, "model": "nvidia/nemotron-nano-12b-v2-vl", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "This is a summarized version of your document..." }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 100, "completion_tokens": 50, "total_tokens": 150 } } ``` ``` -------------------------------- ### Create Python file for AIMLAPI interaction Source: https://docs.aimlapi.com/quickstart/setting-up Creates a new Python file named 'travel.py' where the AIMLAPI interaction code will be placed. This file will contain the script to send prompts to the AIMLAPI and display the responses. ```shell touch travel.py ``` -------------------------------- ### Import OpenAI SDK Source: https://docs.aimlapi.com/quickstart/setting-up Imports the necessary OpenAI SDK class for interacting with the AI/ML API. This step is crucial before initializing any API clients. Supported languages include JavaScript and Python. ```javascript const { OpenAI } = require("openai"); ``` ```python from openai import OpenAI ```