The same API, TypeScript shape
The TS SDK mirrors Python's surface but with TypeScript-friendly object args. Where Python takes model='...', contents='...' as kwargs, TypeScript takes a single object: { model, contents, config }.
response.text is a property
The biggest gotcha when porting from the legacy SDK: response.text is a property, not a method. If you write response.text(), you'll get a "string is not callable" error.
Streaming uses generateContentStream
The streaming function is named differently and returns an async iterable directly:
ai.models.generateContent(...)— single response, awaitable.ai.models.generateContentStream(...)— async iterable of chunks.
Use for await to consume the stream. chunk.text on each chunk gives you the partial text.