I'm writing a story set in an actual city, but I'm not staying true to the reality of it. How much can I invent?

You're putting imagined characters in imagined situations. Why stop there? Plenty of writers invent within real places. You might create a restaurant your characters adore, or have them take a photography class at a fictionalized institute. You might create a mansion nestled on an imagined leafy street. Or populate the Howard Meyer Elementary School with gifted children, even though there's no such school in real life.

But this invention should be anchored in some solid reality. Otherwise, why set the story in that real city? For example, Lake Michigan is a part of every Chicagoan's life, whether they run daily along the lakeside trail or simply navigate city streets knowing the lake indicates east. Making Chicago landlocked would hinder believability. If you're off on that detail, what else can't the reader trust?

Draw on selected realities to give the setting relevance. Why is that city important to this story? Perhaps it's the chaos of downtown, or proximity to the stock exchange where your character works, or the diversity of the population. Draw from those details of reality to bring authenticity to your story. Don't stick to the obvious attributes, as that can make the setting feel like it was written with the aid of a travel guide instead of an intimate understanding of the place. Audrey Niffenegger's novel The Time Traveler's Wife has characters living in Ravenswood, working at the Newberry Library, eating at Ann Sather, and breaking into the Army Surplus store on Belmont. All are Chicago institutions, but not the obvious tourist staples.

If the confines of using a real place makes you feel too bound to reality, you might find it helpful to stay true to the region, but fictionalize the specific place. That's what Charles Baxter did with Five Oaks, Michigan, the setting for several of his fictions, including his novel Saul and Patsy. Five Oaks is entirely fictionalized, but it has the flavor of very real, small, Midwestern towns.

If you do have something geographically unexpected occur in a real place, you'll want to make sure there's good reason behind it, and that inhabitants acknowledge the strangeness. A snowstorm isn't going to rage in Nairobi, Kenya in real life, so if it does in your story, it should be an anomaly, accompanied by increased road accidents, news stories, and a lot of confusion. Indeed, strange things do happen. But if what you imagine really tests the boundaries of what is possible, you might just find that you're dabbling in magic realism.