The Attorney General cabinet position was created on September 24, 1789, with the passage of the Judiciary Act of 1789. This act established the Office of the Attorney General, making it the fourth cabinet-level position created by Congress. While the position was created in 1789, the Department of Justice, which the Attorney General heads, wasn't established until 1870.
And there shall also be appointed a meet person, learned in the law, to act as attorney-general for the United States, who shall be sworn or affirmed to a faithful execution of his office; whose duty it shall be to prosecute and conduct all suits in the Supreme Court in which the United States shall be concerned, and to give his advice and opinion upon questions of law when required by the President of the United States, or when requested by the heads of any of the departments, touching any matters that may concern their departments, and shall receive such compensation for his services as shall by law be provided.