# Connect an n8n AI Agent to a Custom Chat Model Endpoint

In n8n 2.50.0 or later, create a Custom Model Endpoint credential for `https://api.promptavenue.com/v1` with your PromptAvenue API key. Connect Custom Endpoint Chat Model to the AI Agent, select an Uncensored model, and set API Format to Chat Completions. Ask the agent to compute `8 × 7` with Calculator, then check for `56` and a Calculator run in the execution.

[Model pricing](https://promptavenue.com/pricing) · [Run the API quickstart](https://promptavenue.com/docs/quickstart)

## What you need

- A [PromptAvenue account](https://api.promptavenue.com/sign-up?utm_source=docs&utm_medium=guide&utm_campaign=n8n) with API balance.
- n8n 2.50.0 or later with access to the workflow editor and credential creation.

## 1. Create a PromptAvenue API key

In the PromptAvenue dashboard, open the API keys page and select **Create API key**. Copy the full key when it appears.

## 2. Create a credential for the OpenAI-compatible base URL

Create a **Custom Model Endpoint** credential named **PromptAvenue**.

| Field | Value |
| --- | --- |
| Base URL | `https://api.promptavenue.com/v1` |
| Authentication | **Bearer Token** |
| API Key | Your PromptAvenue key |

Paste the key on its own. n8n adds the `Bearer` prefix and appends the API route to the base URL.

## 3. Set up the Custom Endpoint Chat Model

1. Create a workflow with a **Chat Trigger** connected to an **AI Agent**.
2. Attach **Custom Endpoint Chat Model** to the agent's **Chat Model** input. Choose **Custom Model Endpoint** as the authentication type and select the **PromptAvenue** credential.
3. Connect a **Calculator** node to the AI Agent’s **Tool** input.
4. Under **Model**, use **From List** if your model appears, or choose **By ID** and enter `deepseek-v4.1-flash-uncensored`. Set **API Format** to **Chat Completions**.
5. Set the Chat Trigger’s **Response Mode** to **Streaming response** and enable **Enable Streaming** on the AI Agent.
6. Save the workflow. If you already use an OpenAI Chat Model with a base URL override, follow [n8n's migration steps](https://docs.n8n.io/integrations/builtin/credentials/custommodelendpoint#moving-from-the-openai-node-with-a-custom-base-url).

## 4. Verify the AI Agent response

Open the trigger's chat in the workflow editor. Ask the agent to use Calculator to compute 8 × 7.

Expect the chat to show `56`. Open the execution to confirm that the model and Calculator ran successfully.

## Common errors

| Symptom | What to check |
| --- | --- |
| Custom Endpoint Chat Model is missing | Check your n8n version. The node is available from 2.50.0. |
| Authentication or route error | Check the key saved in the credential, select Bearer Token, and use the `/v1` base URL and Chat Completions format. |
| Model is absent from the list | Select **By ID** and enter the exact PromptAvenue model ID. |
| Tool-call error | Check the gateway error and verify that the chosen model supports tool calls in a streamed response. |
| Balance or rate-limit error | Check the dashboard balance if the error mentions funds. For rate limits, wait before retrying. |
