> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate Code • AI Agent SDK

> generate_code: Generate a new pairing code for a channel.

# generate\_code

<div className="flex items-center gap-2">
  <Badge color="purple">Method</Badge>
</div>

> This is a method of the [**PairingProtocol**](../classes/PairingProtocol) class in the [**protocols**](../modules/protocols) module.

Generate a new pairing code for a channel.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def generate_code(channel_type: str, channel_id: Optional[str]) -> str
```

## Parameters

<ParamField query="channel_type" type="str" required={false} default="'unknown'">
  Type of channel (e.g., "telegram", "slack", "ui")
</ParamField>

<ParamField query="channel_id" type="Optional[str]" required={false}>
  Optional channel identifier
</ParamField>

### Returns

<ResponseField name="Returns" type="str">
  The generated pairing code
</ResponseField>

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/gateway/protocols.py#L2160">
  `praisonaiagents/gateway/protocols.py` at line 2160
</Card>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Code Agent" icon="code" href="/docs/docs/features/codeagent" />

  <Card title="Code Feature" icon="terminal" href="/docs/docs/features/code" />
</CardGroup>
