Skip to content
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ building apps that use the Gemini API.
npx skills add google-gemini/gemini-skills --skill gemini-api-dev --global
```

### interactions-api

Skill for building interactive chat experiences with the Gemini Interactions API.
Provides best practices for managing conversation state and turn-based interactions.

```sh
npx skills add google-gemini/gemini-skills --skill interactions-api --global
```

## Disclaimer

This is not an officially supported Google product. This project is not
Expand Down
69 changes: 69 additions & 0 deletions skills/interactions-api/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
name: interactions-api
description: Use this skill when working with the Gemini Interactions API for building interactive chat experiences, managing conversation state, and implementing turn-based interactions with Gemini models.
---

# Gemini Interactions API Skill

## Overview

The Gemini Interactions API provides a structured way to build interactive conversational experiences with Gemini models. Key capabilities include:
- **Interactive Chat** - Build multi-turn conversations
- **State Management** - Maintain conversation context across interactions
- **Turn-based Communication** - Structured request/response patterns
- **Session Handling** - Manage conversation sessions efficiently

## Quick Start

### Python
```python
import google.generativeai as genai
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the main drivers for this skill is to stop LLMs from using this deprecated SDK. I don't mind if you use an LLM to bootstrap the skill but please 1) test it and 2) use the gemini-api-dev skill.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested all the example code locally and have referenced the gemini-api-dev skill. I have made few commits regarding the same. please check it out and let me know if any changes are required.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we update this to match the official docs.

Copy link
Copy Markdown
Author

@Antovex Antovex Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will include the same imports as official documentation


# Assumes GOOGLE_API_KEY is set as an environment variable
model = genai.GenerativeModel('gemini-1.5-flash-latest')
chat = model.start_chat()
response = chat.send_message("Hello there! Can you tell me a joke?")
print(response.text)
```

### JavaScript/TypeScript
```typescript
import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

// To start a chat, use startChat()
async function runChat() {
const model = ai.getGenerativeModel({ model: "gemini-1.5-flash-latest" });
const chat = model.startChat();
const result = await chat.sendMessage("Hello there! Can you tell me a joke?");
const response = await result.response;
const text = response.text();
console.log(text);
}

runChat();
```

## Resources

- [Official Interactions API Documentation](https://ai.google.dev/gemini-api/docs/interactions?ua=chat)
- [Gemini API Reference](https://ai.google.dev/api)

## Best Practices

1. **Maintain Context**: Keep track of conversation history for coherent interactions
2. **Handle State**: Properly manage session state between turns
3. **Error Handling**: Implement robust error handling for network and API issues
4. **Rate Limiting**: Be mindful of API rate limits in interactive scenarios

## Common Use Cases

- Multi-turn chatbots
- Interactive assistants
- Conversational interfaces
- Context-aware Q&A systems

---

For more details, refer to the [official documentation](https://ai.google.dev/gemini-api/docs/interactions?ua=chat).