You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: fern/customization/custom-llm/using-your-server.mdx
+37Lines changed: 37 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -63,6 +63,43 @@ Paste the public URL generated by ngrok (e.g., https://your-unique-id.ngrok.io)
63
63
**4. Test the Connection:**
64
64
Send a test message through the Vapi interface to ensure it reaches your local server and receives a response from the OpenAI API. Verify that the response is displayed correctly in Vapi.
65
65
66
+
## Authentication (Optional)
67
+
68
+
For production deployments, you can secure your custom LLM endpoint using authentication. This ensures only authorized requests from Vapi can access your LLM server.
Vapi supports two authentication methods for custom LLMs:
75
+
76
+
1.**API Key**: Simple authentication where Vapi includes a static API key in request headers. Your server validates this key to authorize requests.
77
+
78
+
2.**OAuth2 Credentials**: More secure authentication using OAuth2 client credentials flow with automatic token refresh.
79
+
80
+
### API Key Authentication
81
+
82
+
When using API Key authentication:
83
+
- Vapi sends your API key in the Authorization header to your custom LLM endpoint
84
+
- Your server validates the API key before processing the request
85
+
- Simple to implement and suitable for basic security requirements
86
+
87
+
### OAuth2 Authentication
88
+
89
+
When configuring OAuth2 in the Vapi dashboard:
90
+
91
+
1.**OAuth2 URL**: Enter your OAuth2 token endpoint (e.g., `https://your-server.com/oauth/token`)
92
+
2.**OAuth2 Client ID**: Your OAuth2 client identifier
93
+
3.**OAuth2 Client Secret**: Your OAuth2 client secret
94
+
95
+
### How OAuth2 Works
96
+
97
+
1. Vapi requests an access token from your OAuth2 endpoint using client credentials
98
+
2. Your server validates the credentials and returns an access token
99
+
3. Vapi includes the token in the Authorization header for LLM requests
100
+
4. Your server validates the token before processing requests
101
+
5. Tokens automatically refresh when they expire
102
+
66
103
## Step 3: Understanding the Communication Flow
67
104
**1. Vapi Sends POST Request:**
68
105
When a user interacts with your Vapi application, Vapi sends a POST request containing conversation context and metadata to the configured endpoint (your ngrok URL).
"scope": "read write"// Optional, only if scope was requested
114
+
"expires_in": 3600
102
115
}
103
116
```
104
117
@@ -116,3 +129,5 @@ Common error types:
116
129
-`invalid_grant`: Invalid or expired refresh token
117
130
-`invalid_scope`: Invalid scope requested
118
131
-`unauthorized_client`: Client not authorized for this grant type
132
+
133
+
<Note> If using the OAuth2 flow for authenticating tool calls, make sure the server for the tool is the URL that should be hit *after* we have completed the token exchange. </Note>
0 commit comments