Skip to main content
You are currently on a page documenting the use of AI/ML API models as text completion models. Many of the latest and most popular AI/ML API models are chat completion models.You may be looking for the AI/ML API chat docs.
This page helps you get started with AI/ML API text completion models.

Overview

Integration details

Model features

Setup

To access AI/ML API models you’ll need to create an account, get an API key, and install the langchain-aimlapi integration package.

Credentials

Head to aimlapi.com to sign up and generate an API key. Once you’ve done this set the AIMLAPI_API_KEY environment variable:
To enable automated tracing of your model calls, set your LangSmith API key:

Installation

The LangChain AI/ML API integration lives in the langchain-aimlapi package:

Instantiation

Now we can instantiate our model object and generate text completions:

Invocation

Streaming invocation

You can also stream responses token-by-token: