# Enum Role

java.lang.Object
java.lang.Enum<Role>
com.codename1.ai.Role

All Implemented Interfaces:
  `Comparable<Role>`

public enum Role extends Enum<Role>
Author of a `ChatMessage`. Maps directly to the role string sent on the wire by every supported LLM provider.

- ## Enum Constant Summary

  Enum Constants
  Enum Constant
  Description
  `ASSISTANT`
  Model output.
  `SYSTEM`
  Developer-supplied instructions that steer the assistant.
  `TOOL`
  Result of a function/tool invocation, sent back to the model so it can continue reasoning.
  `USER`
  End-user content (text, images, tool results).

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static Role`
  `valueOf(String name)`
  Returns the enum constant of this type with the specified name.
  `static Role[]`
  `values()`
  Returns an array containing the constants of this enum type, in the order they are declared.

  ### Methods inherited from class Enum

  `clone, compareTo, equals, getDeclaringClass, getEnumValues, hashCode, name, ordinal, setEnumValues, toString, valueOf`

  ### Methods inherited from class Object

  `getClass, notify, notifyAll, wait, wait, wait`

- ## Enum Constant Details

  - ### SYSTEM

    public static final Role SYSTEM
    Developer-supplied instructions that steer the assistant. Sent once at the head of the conversation. Gemini receives these as `systemInstruction` rather than a normal message; the Gemini client handles the conversion internally.

  - ### USER

    public static final Role USER
    End-user content (text, images, tool results).

  - ### ASSISTANT

    public static final Role ASSISTANT
    Model output. When the assistant calls a tool the `ChatMessage` also carries one or more `ToolCall` entries.

  - ### TOOL

    public static final Role TOOL
    Result of a function/tool invocation, sent back to the model so it can continue reasoning. Paired with the originating `ToolCall` via `ChatMessage.getToolCallId()`.

- ## Method Details

  - ### values

    public static Role[] values()
    Returns an array containing the constants of this enum type, in the order they are declared.
    Returns:
      an array containing the constants of this enum type, in the order they are declared

  - ### valueOf

    public static Role valueOf(String name)
    Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
    Parameters:
      `name` - the name of the enum constant to be returned.
    Returns:
      the enum constant with the specified name
    Throws:
      `IllegalArgumentException` - if this enum type has no constant with the specified name
      `NullPointerException` - if the argument is null