> For the complete documentation index, see [llms.txt](https://docs.agentlabs.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.agentlabs.dev/getting-started/using-the-sdk.md).

# Using the SDK

## Basic example

Since we provide the entire UI and streaming for you, you only have to listen for messages from the front end and send messages from your backend.\
\
Here's a dead simple example of a ping-pong app. Indeed, you can make much more complex applications with multiple agents streaming in real time.

{% tabs %}
{% tab title="Typescript" %}

```typescript
import { Project } from 'agentlabs-sdk';

const project = new Project({
    projectId: 'you-project-id',
    secret: 'your-secret',
    url: 'provided-in-your-console'
});

const agent = project.agent('agent-id');

project.onChatMessage((message) => {
  if (message.text === 'ping') {
     agent.send({
        conversationId: message.conversationId,
        text: 'pong'
     })
  } else {
     agent.send({
        conversationId: message.conversationId,
        text: 'I do not understand'
     })
  }
});

project.connect()
```

{% endtab %}

{% tab title="Python" %}

```python
from agentlabs.project import IncomingChatMessage, MessageFormat, Project

def handle_message(message: IncomingChatMessage):
    if message.text == 'ping':
        agent.send(
            conversation_id=message.conversation_id,
            text="pong"
        )
    else:
        agent.send(
            conversation_id=message.conversation_id,
            text="I did not get that"
        )


project = Project(
        project_id='your-project-id',
        secret='your-secret',
        url='provided-in-your-console'
)

agent = project.agent('agent-id')

project.on_chat_message(handle_message)

project.connect()
project.wait();
```

{% endtab %}
{% endtabs %}

**Next**

Learn more about our core concepts and follow some recipes to get started.

{% content-ref url="/pages/R21c8oRX2G4mrfFHm89J" %}
[Core Concepts](/core-concepts/frontend-as-a-service.md)
{% endcontent-ref %}

{% content-ref url="/pages/ni06RdZYDOeTtrhHPfQA" %}
[Recipes](/recipes/before-we-start.md)
{% endcontent-ref %}
