AskNews Logo Dark

Chat

The chat endpoint is an AI assistant infused with live news. You can ask it questions about the news, and it will respond with the latest information. You can also choose the model you'd like to use:

  • gpt-4o-mini Fast response, but less intelligent (default, Fast tier).
  • gpt-4o Fast response, rich and intelligent (Rich tier).
  • claude-3-5-sonnet-20240620 The latest Claude model (Rich tier).
  • meta-llama/Meta-Llama-3-70B-Instruct Defaults to latest Llama-3-70b model (Fast tier).
  • meta-llama/Meta-Llama-3.1-70B-Instruct Defaults to latest Llama-3.1-70b model (Fast tier).
  • meta-llama/Meta-Llama-3.1-405B-Instruct Defaults to latest Llama-3.1-405b model (Rich tier).

Wanna test it out or request a new model? You can come to our Discord server to talk directly to the bot, or ask us to integrate new models Discord

Querying the Chat endpoint

The chat endpoint follows the OpenAI format for chat completions. The simplest way to use it is to use our pre-built SDK. The SDK will handle the authentication and response parsing for you. If you prefer to use the OpenAI SDK, you can use the same endpoint with the same parameters.

AskNews SDK

Controlling the output

You can control many aspects of the output including:

  • inline_citations: Whether to include inline citations in the response, and how to represent those (e.g. markdown links or numbers)
  • journalist_mode: Whether to activate our journalist mode, which ensures higher journalistic integrity, such as supporting claims with evidence and improved journalistic styling, better self citing. If journalist_mode is deactivated, the AI operates with a barebones prompt, it is up to you to add your prompt for handling citations and output style.
  • append_references: Whether or not to append all the references to the end of the output with image links and article links.
  • asknews_watermark: Whether or not to inclue "Generated by AI at AskNews on (date)" at the end of the output. This is important for tracking and transparency if used in public domains, but you can remove it by setting this parameter to False.

OpenAI SDK

It is possible to use the OpenAI SDK to query the chat endpoint. The AskNews API uses OAuth 2.0 for authentication instead of API keys. In order to use the OpenAI SDK with the AskNews API you must first obtain an access token, then pass it in the Authorization header much like you would with an API key. Luckily, there are plenty of libraries that can help handle this for you. The OpenAI SDK uses httpx underneath the hood, and allows us to pass a custom client when using it. For the OAuth 2.0 handling, there is a great simple little package named httpx_auth that already implements the OAuth 2.0 handling for us. Below is an example of how to use the OpenAI SDK with these libraries to easily set this up:

You can also include the extra AskNews parameters in your OpenAI client (or langchain client) requests by adding them to the extra_body parameter.

Detailed and updated response structures are always available in the API reference

    We use cookies

    We use cookies to ensure you get the best experience on our website. Some of these cookies are provided by third parties. You are free to decide which categories you would like to permit and can withdraw this consent at any time (via cookie preferences link on the footer).

    You can either accept all cookies, reject all but the necessary cookies or click the "Preferences" button to decide which cookie categories you would like to enable or disable.
    Learn more on our privacy policy page.