Skip to main content
connic
Connectors

Kafka

Start agents from messages in an Apache Kafka topic, or publish run results to a topic.

Last updated
ModesInbound, outbound
YAML typekafka
CredentialsA Connection of type kafka with the brokers and security settings
BridgeOn the Connection, to reach brokers in a private network
Custom domainNot supported
Linked agentsOne or more. A message starts every linked agent.
While pausedInbound: connic stops reading. Messages stay in the topic and are processed after resume, from the consumer group's last committed offset, so they must still be within the topic's retention. Outbound: nothing is published.
New connectorsInbound connectors are created paused in the dashboard, and through the REST API or connic MCP unless the request sets enabled: true. Start them with Resume. Connectors in code start active.

Set up

  1. Create the topic in your cluster. For outbound, the broker can also create it on the first publish if automatic topic creation is on.

  2. Open the agent. In Connector Flow, click Add inbound connector for inbound or Add outbound connector for outbound. Then click Create New Connector and select Apache Kafka.

  3. Choose Inbound (Consumer) or Outbound (Producer). Under Connection, pick a saved Connection or create one with the brokers and security settings; see Connection. If the brokers are in a private network, select the Bridge in the Connection.

  4. Enter the Topic. For inbound, optionally set Consumer Group ID and Auto Offset Reset.

  5. Click Create. A new inbound connector is paused: click Resume in its details drawer to start consuming. To reopen the drawer, hover over the connector in the flow and click the eye icon.

In code

Declare the connector in connectors/*.yaml. The file names the Connection and never contains broker credentials. Connectors in code start active, so an inbound connector starts consuming when its first deploy goes live.

connectors/order-events.yaml
type: kafka
mode: inbound
connection: orders-kafka      # Connection with the brokers, credentials, and optional Bridge
config:
  topic: orders
  group_id: connic-orders
  auto_offset_reset: earliest
agents:
  - order-processor
connectors/order-results.yaml
type: kafka
mode: outbound
connection: orders-kafka
config:
  topic: order-results
agents:
  - name: order-processor
    outbound: { usage: automatic }

Configuration

The fields of a Kafka connector, the same in connectors/*.yaml, the REST API, and connic MCP. The descriptions name the matching setting in the dashboard. Connectors in code describes the fields every connector shares, such as agents and environments.

FieldTypeStatusDescription
typestringRequiredkafka.
modestringRequiredinbound or outbound. Dashboard: Mode.
connectionstringRequiredName or ID of a Connection of type kafka, which holds the brokers, the security settings, and the Bridge. See Connection. Dashboard: Connection.
configobjectRequiredKafka settings.
topicstringRequiredInbound and outbound. The topic to consume from or publish to. A connector uses one topic. Dashboard: Topic.
group_idstringOptionalInbound. The consumer group the connector joins. When it's empty at creation, connic generates one; see Generated values. A new group ID starts a new consumer group, which begins where auto_offset_reset says. Dashboard: Consumer Group ID.
auto_offset_resetstringOptionalInbound. Where a consumer group without a committed offset starts: latest reads messages produced after the consumer starts, earliest reads from the oldest message still in the topic. Dashboard: Auto Offset Reset.Default: latest

Connection

A Connection of type kafka holds these fields. Every Kafka connector in the project can use it, and a connector's config doesn't take them. Manage Connections in Project Settings → Connections or through the REST API.

FieldTypeStatusDescription
bootstrap_serversstringRequiredComma-separated broker addresses, such as broker-1.example.com:9092,broker-2.example.com:9092. Without a Bridge, the bootstrap servers and every broker the cluster advertises must resolve only to public IP addresses. Dashboard: Bootstrap Servers.
security_protocolstringOptionalPLAINTEXT, SSL, SASL_PLAINTEXT, or SASL_SSL. Dashboard: Security Protocol.Default: PLAINTEXT
sasl_mechanismstringOptionalSASL protocols. PLAIN, SCRAM-SHA-256, or SCRAM-SHA-512. Dashboard: SASL Mechanism.Default: PLAIN
sasl_usernamestringOptionalRequired for SASL protocols. Dashboard: SASL Username.
sasl_passwordstringOptionalRequired for SASL protocols. Secret. Dashboard: SASL Password.
ssl_ca_pemstringOptionalSSL protocols. CA certificate in PEM format that the broker certificates are checked against. Secret. Dashboard: SSL CA Certificate PEM.
ssl_cert_pemstringOptionalSSL protocols. Client certificate in PEM format for mutual TLS. Set it together with ssl_key_pem. Secret. Dashboard: SSL Client Certificate PEM.
ssl_key_pemstringOptionalSSL protocols. Client private key in PEM format. Set it together with ssl_cert_pem. Secret. Dashboard: SSL Client Key PEM.
ssl_passwordstringOptionalSSL protocols. Password of an encrypted client key. Secret. Dashboard: SSL Key Password.
ssl_check_hostnamebooleanOptionalSSL protocols. Check broker hostnames against their TLS certificates. Dashboard: Verify SSL Hostname.Default: true
bridgestringOptionalName or ID of the Bridge that reaches brokers in a private network. connic routes the bootstrap servers and every broker the cluster advertises through it. The REST API and connic MCP take it as the Connection's top-level bridge, not in config. Dashboard: Bridge.

Paste certificate and key contents, not file paths. connic rejects ssl_cafile, ssl_certfile, and ssl_keyfile.

Every connector that uses the Connection goes through its Bridge. To use a different Bridge per environment, give each environment its own Connection; see Connections and Bridges. When you change the bootstrap servers, the security settings, or the Bridge of a saved Connection, enter the SASL password and the TLS secrets it holds again; connic refuses the change otherwise.

Generated values

connic generates this value when the connector is created without it, keeps it across updates and deploys, and shows it in the details drawer. You can also set it yourself in config.group_id.

ValueModesDescription
Consumer Group IDInboundconnic-consumer- followed by 16 hexadecimal characters, when group_id is empty at creation. It stays when later updates or deploys leave group_id out.

Agent input

Modes: Inbound

Each message becomes the input of every linked agent. A JSON object keeps its fields, and connic adds the message metadata under _kafka:

payload.json
{
  "order_id": "12345",
  "customer": "john@example.com",
  "items": ["widget-a", "widget-b"],
  "_kafka": {
    "topic": "orders",
    "partition": 0,
    "offset": 1542,
    "timestamp": 1768473000000,
    "key": "order-12345"
  }
}

_kafka holds the topic, partition, and offset, the message timestamp in milliseconds since the Unix epoch, and the message key as a string, or null for a message without a key.

Any other value is wrapped under message: other JSON values as parsed, and text that isn't JSON as a string. A message without a value, such as a tombstone in a compacted topic, still starts runs, with message: null. Use _kafka.key to identify the deleted record:

tombstone.json
{
  "message": null,
  "_kafka": {
    "topic": "orders",
    "partition": 0,
    "offset": 1543,
    "timestamp": 1768473000000,
    "key": "order-12345"
  }
}

A JSON object can carry files in a files array. Each file has a name, a mime_type, and base64-encoded data. connic accepts up to 50 complete files, at most 32 MiB combined. Invalid files are omitted one by one. At the first file over a limit, connic keeps the files before it and accepts no further files. Each omitted file is described in file_issues, and the run continues without it.

Files are optional by default. Turn on Files required for an agent in the connector's details drawer, or set files_required: true on its link in YAML, to fail the run before it starts when a file is missing or was omitted.

Consumer groups

Modes: Inbound

Each inbound connector reads its topic as a member of its consumer group, and Kafka keeps the group's committed offsets. Connectors with different group IDs each receive every message. Connectors with the same group ID share the work: Kafka assigns each partition to one of them.

A connector reads its partitions one message at a time. To consume a high-volume topic in parallel, create several inbound connectors with the same group ID and link them to the same agent.

To consume several topics, create one inbound connector per topic and link them to the same agent. _kafka.topic tells the events apart, and _kafka.key or a shared field, such as an order ID, correlates them.

Deleting a connector doesn't delete its consumer group's offsets in Kafka.

Delivery and ordering

Modes: Inbound

connic commits a message's offset once it has stored a queued run for every linked agent, before those runs execute. Stored runs survive worker restarts and deployments.

A message that is read again after a partial failure, a restart before its offset was committed, or a consumer group rebalance reuses the run already stored for it. Each agent gets one run per message and consumer group, also across connectors that share a group ID.

A run that fails after it was stored causes no redelivery and no dead-letter message. The failed run keeps its full input, so you can rerun it. Retries inside a run follow the agent's retry_options.

Runs are stored in offset order but execute in parallel up to max_concurrent_runs, so two messages with the same key can run at the same time. For per-key ordering, add a concurrency rule on the message key:

agents/order-processor.yaml
concurrency:
  key: _kafka.key
  on_conflict: queue

Runs for the same key then start one at a time in arrival order, while different keys still run in parallel. A failed run releases its key, so the next message for that key still runs. The rule doesn't apply to messages without a key.

Outbound delivery

Modes: Outbound

An outbound Kafka connector publishes JSON messages to its topic. It publishes when a linked agent's run completes, when the model calls it as a tool, or when middleware calls it, depending on the link's usage.

Automatic payload

An automatic link publishes the completed run as the message value:

payload.json
{
  "run_id": "550e8400-e29b-41d4-a716-446655440000",
  "agent_name": "order-processor",
  "status": "completed",
  "output": "Order processed successfully. Total: $234.56",
  "error": null,
  "started_at": "2026-01-15T10:30:00Z",
  "ended_at": "2026-01-15T10:30:05Z",
  "token_usage": {
    "input_tokens": 150,
    "output_tokens": 50,
    "thinking_tokens": 0,
    "cached_input_tokens": 0,
    "total_tokens": 200
  }
}

The message key is the key of the Kafka message that started the run, so results for one key go to the same partition. Other runs, and runs from messages without a key, use the run ID. To build a pipeline, link an inbound Kafka connector and an automatic outbound Kafka connector to the same agent; the agent's output arrives in output.

Automatic sources describes which runs publish. A run that middleware ends with StopProcessing counts as completed and publishes the StopProcessing response as its output, unless it is raised with publish_outbound=False. That flag doesn't undo an agent-tool or middleware call made earlier in the run.

Agent-tool and middleware payload

The model or middleware passes the message value under payload and an optional message key. connic publishes the value of payload and adds the topic, credentials, serialization, retries, and Bridge routing, none of which the model sees.

connector-payload.json
{
  "payload": {
    "order_id": "12345",
    "status": "approved"
  },
  "key": "order-12345"
}

Without key, the message key is the payload's run_id field if it has one, otherwise a new ID for each send.

Delivery and retries

Each message has a JSON value, a UTF-8 key, and no headers. connic waits until all in-sync replicas acknowledge the message (acks=all). Each attempt waits up to 10 seconds for the acknowledgment, and a failed publish is tried 3 times in total, waiting 1 and then 2 seconds between attempts. The connector's runs show each delivery and its error.

Limits and errors

SituationWhat happens
A message value or key isn't valid UTF-8connic records a failed connector run, commits the offset, and starts no agent run.
Storing a run failsThe offset stays uncommitted, and the consumer reads the same message again after a short delay. Later messages on the connector wait until it succeeds.
No agent is linkedconnic commits each message without starting a run and records it as a connector run with No agents linked.
A broker or network errorThe consumer reconnects with exponential backoff, from 5 seconds up to 2 minutes, and resumes from the last committed offset.
Authentication or authorization failsThe consumer stops and writes the error to the connector logs. It starts again when you update the connector or its Connection, or pause and resume it.
Publishing fails (outbound)connic makes up to 3 attempts, then marks the delivery as failed. See Delivery and retries.