Skip to content

Instantly share code, notes, and snippets.

@acheong08
Created May 27, 2023 10:58
Show Gist options
  • Save acheong08/be0b43bb89f9f4797079e5948c48738c to your computer and use it in GitHub Desktop.
Save acheong08/be0b43bb89f9f4797079e5948c48738c to your computer and use it in GitHub Desktop.
A guide on how to reverse engineer character.ai

Authentication:

  • Set cookies from your browser

Step 1: GET https://beta.character.ai/chat/curated_categories/characters/. It returns JSON. You are looking for external_id of the character you want. This will be used for all following steps (external_id or character_external_id)

Step 2: POST https://beta.character.ai/chat/character/info/ with {"external_id":"..."} as payload. Keep track of identifier from the response as tgt for step 4

Step 3: POST https://beta.character.ai/chat/history/create/ with the same payload as step 2. Keep track of external_id in the response as history_external_id.

Step 4: POST https://beta.character.ai/chat/streaming/ with payload:

{
    "history_external_id": "<HISTORY ID from STEP 3>",
    "character_external_id": "<CHARACTER ID from STEP 1>",
    "text": "<YOUR PROMPT>",
    "tgt": "<TGT from STEP 2>",
    "ranking_method": "random",
    "staging": false,
    "model_server_address": null,
    "model_server_address_exp_chars": null,
    "override_prefix": null,
    "override_rank": null,
    "rank_candidates": null,
    "filter_candidates": null,
    "unsanitized_characters": null,
    "prefix_limit": null,
    "prefix_token_limit": null,
    "stream_params": null,
    "model_properties_version_keys": "",
    "enable_tti": null,
    "initial_timeout": null,
    "insert_beginning": null,
    "stream_every_n_steps": 16,
    "chunks_to_pad": 8,
    "is_proactive": false,
    "image_rel_path": "",
    "image_description": "",
    "image_description_type": "",
    "image_origin_type": "",
    "voice_enabled": false,
    "parent_msg_uuid": null,
    "seen_msg_uuids": [],
    "retry_last_user_msg_uuid": null,
    "num_candidates": 1,
    "give_room_introductions": true,
    "mock_response": false
}

CLOUDFLARE!!! Use TLS spoofing! If you need help with this, look at my ChatGPT-Proxy-V4 code. You must write the program in Go or else it won't stream.

@Yorddyyorddy
Copy link

Still can't bypass but I haven't used proxy as I don't have any

Btw they have launched an app called c chat can we figure out how it calls their api end point

@fw-real
Copy link

fw-real commented Apr 30, 2024

yall still workin on this?

@acheong08
Copy link
Author

I wrote this as a response to some random Discord user and posted it as a gist as reference for anyone interested. There was never any intention to do anything with it.

AI hasn't really been that interesting beyond the initial hype.

@fw-real
Copy link

fw-real commented May 1, 2024

I wrote this as a response to some random Discord user and posted it as a gist as reference for anyone interested. There was never any intention to do anything with it.

AI hasn't really been that interesting beyond the initial hype.

oh alr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment