You should only use the
OpenAILike and OpenAIEmbedding classes from LlamaIndex. These classes are designed for custom OpenAI-compatible endpoints, allowing you to use your TrueFoundry-specific model names directly. Using the standard OpenAI class will cause errors, as it validates model names against OpenAI’s public list.Prerequisites
Before you begin, ensure you have the following:- Authentication Token: A TrueFoundry API key. Follow the instructions in Generating Tokens to create one.
- Gateway Base URL: Your TrueFoundry Gateway Base URL (
{GATEWAY_BASE_URL}). See Authentication for details.
Code Examples
The following examples demonstrate how to use LlamaIndex with TrueFoundry.Chat Completion
This example shows how to perform chat completion.Text Embedding
This example shows how to generate text embeddings.FAQs
Getting 'Unknown model, Please provide a valid OpenAI model name' error?
Getting 'Unknown model, Please provide a valid OpenAI model name' error?
This error usually occurs when you’re using the
The
To fix this, make sure you are using the
OpenAI class from LlamaIndex instead of OpenAILike. The
OpenAI class strictly validates model names against OpenAI’s public list, so any custom or TrueFoundry-specific model name will result in this error. To fix this, make sure you are using the
OpenAILike class, which supports custom, OpenAI-compatible endpoints.