---
title: Unexpected Token
sidebar_position: 2
description: A step-by-step guide to correct syntax errors caused by invalid JSON in the code.
keywords:
  [
    Jan AI,
    Jan,
    ChatGPT alternative,
    local AI,
    private AI,
    conversational AI,
    no-subscription fee,
    large language model,
    troubleshooting,
    unexpected token,
  ]
---

<head>
    <title>Unexpected Token</title>
    <meta name="description" content="A step-by-step guide to correct syntax errors caused by invalid JSON in the code. Learn how to troubleshoot and fix issues related to unexpected token errors when initiating a chat with OpenAI models."/>
    <meta name="keywords" content="Jan AI, Jan, ChatGPT alternative, local AI, private AI, conversational AI, no-subscription fee, large language model, troubleshooting, unexpected token"/>
    <meta property="og:title" content="Unexpected Token"/>
    <meta property="og:description" content="A step-by-step guide to correct syntax errors caused by invalid JSON in the code. Learn how to troubleshoot and fix issues related to unexpected token errors when initiating a chat with OpenAI models."/>
    <meta property="og:url" content="https://jan.ai/unexpected-token"/>
    <meta name="twitter:card" content="summary"/>
    <meta name="twitter:title" content="Unexpected Token"/>
    <meta name="twitter:description" content="A step-by-step guide to correct syntax errors caused by invalid JSON in the code. Learn how to troubleshoot and fix issues related to unexpected token errors when initiating a chat with OpenAI models."/>
</head>

Encountering the `Unexpected token` error when initiating a chat with OpenAI models mainly caused by either your OpenAI key or where you access your OpenAI from. This issue can be solved through the following steps:

1. Obtain an OpenAI API key from [OpenAI's developer platform](https://platform.openai.com/) and integrate it into your application.

2. Trying a VPN could potentially solve the issue, especially if it's related to region locking for accessing OpenAI services. By connecting through a VPN, you may bypass such restrictions and successfully initiate chats with OpenAI models.