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
-**Mistral**: `'Mistral Large 2'`, `'Mistral Large'`, `'Mistral Small'`
15
+
Key constraint: `a.generation()` routes only support Anthropic (Claude) models. `a.conversation()` routes work with any supported model.
18
16
19
17
For models not in the supported list, use the raw escape hatch: `aiModel: { resourcePath: '<bedrock-model-id>' }`.
20
18
21
19
Availability depends on the AWS region and Bedrock model access enablement.
22
20
23
-
> **Note:**`a.generation()` routes only support Anthropic (Claude) models. `a.conversation()` routes work with any supported model.
21
+
### Bedrock Model Access
22
+
23
+
Some older or restricted models require explicit enablement in the AWS Bedrock console (Model access). On-demand foundation models (Claude Sonnet 4+, Nova) are available immediately. Amplify uses global inference profiles for cross-region model access.
24
+
25
+
If you get `AccessDeniedException: Could not access the model with the specified model ID`, check **Bedrock → Model access** in your region.
24
26
25
27
## Backend: Conversation Routes
26
28
@@ -33,7 +35,7 @@ import { a, type ClientSchema } from '@aws-amplify/backend';
33
35
34
36
const schema =a.schema({
35
37
chat: a.conversation({
36
-
aiModel: a.ai.model('Claude 3.5 Sonnet v2'),
38
+
aiModel: a.ai.model('Claude Sonnet 4.5'),
37
39
systemPrompt: 'You are a helpful assistant.',
38
40
})
39
41
.authorization(allow=>allow.owner()),
@@ -44,12 +46,10 @@ const schema = a.schema({
44
46
45
47
Use `a.generation()` for single-turn (stateless) inference.
46
48
47
-
> **MUST:** Only Anthropic (Claude) models support `a.generation()` routes. Non-Anthropic models (Amazon Nova, Meta Llama, Cohere, Mistral) work with `a.conversation()` only.
48
-
49
49
```typescript
50
50
const schema =a.schema({
51
51
summarize: a.generation({
52
-
aiModel: a.ai.model('Claude 3.5 Sonnet v2'),
52
+
aiModel: a.ai.model('Claude Sonnet 4.5'),
53
53
systemPrompt: 'Summarize the provided text concisely.',
**Authorization constraints (these cause TypeError at CDK assembly if violated):**
63
63
64
-
-**Conversation routes** (`a.conversation()`) **MUST** use `allow.owner()` authorization — `allow.authenticated()` and other non-owner strategies throw a TypeError at CDK assembly time (before deployment even begins).
65
-
-**Generation routes** (`a.generation()`) **MUST** use non-owner authorization (`allow.authenticated()`, `allow.guest()`, `allow.group()`, or `allow.publicApiKey()`) — `allow.owner()` throws a TypeError at CDK assembly time (before deployment even begins).
64
+
-**Conversation routes** (`a.conversation()`) require `allow.owner()` authorization — `allow.authenticated()` and other non-owner strategies throw a TypeError at CDK assembly time.
65
+
-**Generation routes** (`a.generation()`) require non-owner authorization (`allow.authenticated()`, `allow.guest()`, `allow.group()`, or `allow.publicApiKey()`) — `allow.owner()` throws a TypeError at CDK assembly time.
66
66
67
67
These constraints are asymmetric and frequently confused. Getting them wrong
68
68
causes the CDK synthesis to fail with a non-obvious TypeError.
@@ -90,7 +90,7 @@ import { myToolFunc } from '../functions/my-tool/resource';
90
90
91
91
const schema =a.schema({
92
92
chat: a.conversation({
93
-
aiModel: a.ai.model('Claude 3.5 Sonnet v2'),
93
+
aiModel: a.ai.model('Claude Sonnet 4.5'),
94
94
systemPrompt: 'You are a helpful assistant with tool access.',
95
95
tools: [
96
96
{
@@ -172,7 +172,7 @@ Pagination: use `limit` and `nextToken` parameters on `.list()`.
172
172
173
173
Subscribe to streaming responses for real-time token delivery:
174
174
175
-
In React, **MUST**wrap in `useEffect` and return the cleanup function:
175
+
In React, wrap in `useEffect` and return the cleanup function:
176
176
177
177
```tsx
178
178
useEffect(() => {
@@ -191,18 +191,6 @@ useEffect(() => {
191
191
192
192
## Pitfalls
193
193
194
-
-**Conversation auth MUST be `allow.owner()`:** Using
195
-
`allow.authenticated()` or any other non-owner strategy on
196
-
`a.conversation()` throws a TypeError at CDK assembly time.
197
-
-**Generation auth MUST NOT be `allow.owner()`:** Using
198
-
`allow.owner()` on `a.generation()` throws a TypeError at CDK assembly
199
-
time. Use `allow.authenticated()`, `allow.guest()`, or `allow.group()`.
200
-
-**Missing AI route in data schema:** The conversation or generation
201
-
route **MUST** be defined in your `a.schema()` — without it, the
202
-
frontend client has no AI endpoint to call.
203
-
-**Model availability:** Not all Bedrock models are enabled by default —
204
-
you **MUST** enable model access in the AWS console (Bedrock → Model
205
-
access) before using a model in `a.ai.model()`.
206
194
-**Message content structure:** Both `sendMessage('Hello')` (string) and
207
195
`sendMessage({ content: [{ text: 'Hello' }] })` (object) are valid. Use
208
196
the object form when sending images or tool results.
Set secrets via CLI: `echo "<value>" | npx ampx sandbox secret set GOOGLE_CLIENT_ID`.
126
-
For provider-specific OAuth setup guides, **SHOULD**consult AWS
127
-
documentation via available tools; when unavailable, **MUST**use web
127
+
Set secrets via CLI: `echo -n "<value>" | npx ampx sandbox secret set MY_OAUTH_CLIENT_ID`. (The documented approach uses an interactive prompt; piping with `echo -n` is a practical alternative for scripts.)
128
+
For provider-specific OAuth setup guides, consult AWS
129
+
documentation via available tools; when unavailable, use web
128
130
search or AWS CLI.
129
131
130
132
## SAML / OIDC (Enterprise)
131
133
132
-
OIDC providers are configured directly in `externalProviders`:
134
+
OIDC providers are configured inside `loginWith.externalProviders`:
**SAML** is NOT supported in `defineAuth` — the `ExternalProviderSpecificFactoryProps` type has no `saml` property. The lower-level `auth-construct` package supports SAML, but it was never wired up to the high-level API. Use CDK escape hatches via `backend.auth.resources` to configure SAML providers:
@@ -182,17 +191,45 @@ import { defineFunction } from '@aws-amplify/backend';
1.**Separate DynamoDB table** — create via CDK (not `defineData`) to avoid stack coupling.
211
+
185
212
## Guest (Unauthenticated) Access
186
213
187
214
Guest access is **enabled by default** in Amplify Gen2 — the Cognito Identity Pool is created with `allowUnauthenticatedIdentities: true` automatically.
188
215
189
-
To use guest access in your data models, set `defaultAuthorizationMode` to `'iam'`:
216
+
To use guest access in your data models, set `defaultAuthorizationMode` to `'iam'` and add `allow.guest()` authorization rules:
190
217
191
218
```typescript
219
+
const schema =a.schema({
220
+
Todo: a.model({
221
+
content: a.string(),
222
+
}).authorization(allow=> [
223
+
allow.guest().to(['read']), // unauthenticated users can read
224
+
allow.owner(), // owners can CRUD
225
+
]),
226
+
});
227
+
192
228
exportconst data =defineData({
193
229
schema,
194
230
authorizationModes: {
195
-
defaultAuthorizationMode: 'iam',
231
+
defaultAuthorizationMode: 'iam', // required for guest access
232
+
apiKeyAuthorizationMode: { expiresInDays: 7 }, // optional alternative
0 commit comments