|
| 1 | +--- |
| 2 | +title: The Grid |
| 3 | +subtitle: Use The Grid instruments in Vapi through the custom-llm provider |
| 4 | +description: Wire The Grid, an OpenAI-compatible inference marketplace, into Vapi with the custom-llm provider and Custom Credentials. |
| 5 | +slug: customization/custom-llm/thegrid |
| 6 | +--- |
| 7 | + |
| 8 | +The Grid is an inference marketplace that serves models from several labs behind one OpenAI-compatible API. Its instrument IDs describe capability tiers rather than specific lab models. |
| 9 | + |
| 10 | +`text-standard`, `code-prime`, and `agent-max` each route to a current model for that tier. When The Grid replaces an underlying model, an assistant can keep using the same instrument ID. |
| 11 | + |
| 12 | +The Grid exposes an OpenAI-compatible Chat Completions API, so you can connect it to Vapi as a [custom LLM](/customization/custom-llm/fine-tuned-openai-models). |
| 13 | + |
| 14 | +Before starting, create an account with The Grid and a [Consumption API key](https://thegrid.ai/docs/api-reference/authentication). |
| 15 | + |
| 16 | +## Add your credential |
| 17 | + |
| 18 | +Send the following body to `POST https://api.vapi.ai/credential`. Use your [Vapi private API key](/security-and-privacy/api-keys) in the `Authorization: Bearer <VAPI_PRIVATE_KEY>` header: |
| 19 | + |
| 20 | +```json |
| 21 | +{ |
| 22 | + "provider": "custom-llm", |
| 23 | + "apiKey": "<YOUR THE GRID API KEY>" |
| 24 | +} |
| 25 | +``` |
| 26 | + |
| 27 | +Save the credential `id` from the response. Add it to the assistant's `credentialIds` to select that credential. |
| 28 | + |
| 29 | +## Create the assistant |
| 30 | + |
| 31 | +Send this body to `POST https://api.vapi.ai/assistant` with the same Vapi private API key. Set `model.url` to The Grid's base URL and `model.model` to an instrument ID: |
| 32 | + |
| 33 | +```json |
| 34 | +{ |
| 35 | + "name": "My Assistant", |
| 36 | + "credentialIds": ["<YOUR THE GRID CREDENTIAL ID>"], |
| 37 | + "model": { |
| 38 | + "provider": "custom-llm", |
| 39 | + "url": "https://api.thegrid.ai/v1", |
| 40 | + "model": "text-standard", |
| 41 | + "metadataSendMode": "off", |
| 42 | + "maxTokens": 600, |
| 43 | + "messages": [ |
| 44 | + { |
| 45 | + "role": "system", |
| 46 | + "content": "You are a helpful voice assistant. Keep replies short." |
| 47 | + } |
| 48 | + ] |
| 49 | + } |
| 50 | +} |
| 51 | +``` |
| 52 | + |
| 53 | +Setting `metadataSendMode` to `off` keeps Vapi call metadata out of requests to The Grid. |
| 54 | + |
| 55 | +## Choose an instrument |
| 56 | + |
| 57 | +`GET https://api.thegrid.ai/v1/models` lists available instrument IDs. Check [instrument specifications](https://thegrid.ai/instruments) and [pricing](https://thegrid.ai/pricing) for current details. Examples include: |
| 58 | + |
| 59 | +| Instrument | Use it for | |
| 60 | +| --- | --- | |
| 61 | +| `text-standard` | General conversation. The usual starting point. | |
| 62 | +| `text-prime`, `text-max` | More demanding questions; compare current speed and price. | |
| 63 | +| `agent-standard`, `agent-max` | Multi-step tool use. | |
| 64 | +| `code-standard`, `code-prime` | Assistants that read or write code. | |
| 65 | + |
| 66 | +## Set `maxTokens` for spoken replies |
| 67 | + |
| 68 | +Vapi uses `250` for `maxTokens` when it is omitted and sends the value to The Grid as `max_tokens`. A low cap can cut off a response. |
| 69 | + |
| 70 | +The `600` value in the example is a starting point. Test your chosen instrument with representative spoken turns and raise the limit if replies are truncated. Keep the system prompt explicit about brevity. |
| 71 | + |
| 72 | +## Tool calling |
| 73 | + |
| 74 | +The Grid's API supports OpenAI-style function calling. To configure Vapi tools, see the [tool calling integration guide](/customization/tool-calling-integration). Test a tool call with your chosen instrument before relying on it. |
| 75 | + |
| 76 | +## Verify the assistant |
| 77 | + |
| 78 | +Start a test call and ask the assistant a short question. Confirm it speaks a complete answer. Check the call logs for custom LLM errors. If you attached a tool, request an action that uses it. Confirm the tool runs. |
0 commit comments